Lines Matching +full:set +full:- +full:top

1 // SPDX-License-Identifier: GPL-2.0
20 * osnoise_get_cpus - return the original "osnoise/cpus" content
26 if (context->curr_cpus) in osnoise_get_cpus()
27 return context->curr_cpus; in osnoise_get_cpus()
29 if (context->orig_cpus) in osnoise_get_cpus()
30 return context->orig_cpus; in osnoise_get_cpus()
32 context->orig_cpus = tracefs_instance_file_read(NULL, "osnoise/cpus", NULL); in osnoise_get_cpus()
38 return context->orig_cpus; in osnoise_get_cpus()
42 * osnoise_set_cpus - configure osnoise to run on *cpus
44 * "osnoise/cpus" file is used to set the cpus in which osnoise/timerlat
46 * and set the cpus passed as argument.
55 return -1; in osnoise_set_cpus()
57 context->curr_cpus = strdup(cpus); in osnoise_set_cpus()
58 if (!context->curr_cpus) in osnoise_set_cpus()
59 return -1; in osnoise_set_cpus()
63 debug_msg("setting cpus to %s from %s", cpus, context->orig_cpus); in osnoise_set_cpus()
67 free(context->curr_cpus); in osnoise_set_cpus()
68 context->curr_cpus = NULL; in osnoise_set_cpus()
69 return -1; in osnoise_set_cpus()
76 * osnoise_restore_cpus - restore the original "osnoise/cpus"
86 if (!context->orig_cpus) in osnoise_restore_cpus()
89 if (!context->curr_cpus) in osnoise_restore_cpus()
93 if (!strcmp(context->orig_cpus, context->curr_cpus)) in osnoise_restore_cpus()
96 debug_msg("restoring cpus to %s", context->orig_cpus); in osnoise_restore_cpus()
98 retval = tracefs_instance_file_write(NULL, "osnoise/cpus", context->orig_cpus); in osnoise_restore_cpus()
103 free(context->curr_cpus); in osnoise_restore_cpus()
104 context->curr_cpus = NULL; in osnoise_restore_cpus()
108 * osnoise_put_cpus - restore cpus config and cleanup data
114 if (!context->orig_cpus) in osnoise_put_cpus()
117 free(context->orig_cpus); in osnoise_put_cpus()
118 context->orig_cpus = NULL; in osnoise_put_cpus()
122 * osnoise_read_ll_config - read a long long value from a config
124 * returns -1 on error.
133 return -1; in osnoise_read_ll_config()
135 /* get_llong_from_str returns -1 on error */ in osnoise_read_ll_config()
146 * osnoise_write_ll_config - write a long long value to a config in rel_path
148 * returns -1 on error.
164 * osnoise_get_runtime - return the original "osnoise/runtime_us" value
172 if (context->runtime_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_runtime()
173 return context->runtime_us; in osnoise_get_runtime()
175 if (context->orig_runtime_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_runtime()
176 return context->orig_runtime_us; in osnoise_get_runtime()
182 context->orig_runtime_us = runtime_us; in osnoise_get_runtime()
190 * osnoise_get_period - return the original "osnoise/period_us" value
198 if (context->period_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_period()
199 return context->period_us; in osnoise_get_period()
201 if (context->orig_period_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_period()
202 return context->orig_period_us; in osnoise_get_period()
208 context->orig_period_us = period_us; in osnoise_get_period()
220 if (context->orig_runtime_us == OSNOISE_TIME_INIT_VAL) in __osnoise_write_runtime()
221 return -1; in __osnoise_write_runtime()
225 return -1; in __osnoise_write_runtime()
227 context->runtime_us = runtime; in __osnoise_write_runtime()
236 if (context->orig_period_us == OSNOISE_TIME_INIT_VAL) in __osnoise_write_period()
237 return -1; in __osnoise_write_period()
241 return -1; in __osnoise_write_period()
243 context->period_us = period; in __osnoise_write_period()
248 * osnoise_set_runtime_period - set osnoise runtime and period
252 * to set the runtime and period if they are != 0.
270 return -1; in osnoise_set_runtime_period()
274 return -1; in osnoise_set_runtime_period()
278 return -1; in osnoise_set_runtime_period()
285 return -1; in osnoise_set_runtime_period()
288 return -1; in osnoise_set_runtime_period()
292 return -1; in osnoise_set_runtime_period()
295 return -1; in osnoise_set_runtime_period()
302 * osnoise_restore_runtime_period - restore the original runtime and period
306 unsigned long long orig_runtime = context->orig_runtime_us; in osnoise_restore_runtime_period()
307 unsigned long long orig_period = context->orig_period_us; in osnoise_restore_runtime_period()
308 unsigned long long curr_runtime = context->runtime_us; in osnoise_restore_runtime_period()
309 unsigned long long curr_period = context->period_us; in osnoise_restore_runtime_period()
323 context->runtime_us = OSNOISE_TIME_INIT_VAL; in osnoise_restore_runtime_period()
324 context->period_us = OSNOISE_TIME_INIT_VAL; in osnoise_restore_runtime_period()
328 * osnoise_put_runtime_period - restore original values and cleanup data
334 if (context->orig_runtime_us != OSNOISE_TIME_INIT_VAL) in osnoise_put_runtime_period()
335 context->orig_runtime_us = OSNOISE_TIME_INIT_VAL; in osnoise_put_runtime_period()
337 if (context->orig_period_us != OSNOISE_TIME_INIT_VAL) in osnoise_put_runtime_period()
338 context->orig_period_us = OSNOISE_TIME_INIT_VAL; in osnoise_put_runtime_period()
342 * osnoise_get_timerlat_period_us - read and save the original "timerlat_period_us"
349 if (context->timerlat_period_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_timerlat_period_us()
350 return context->timerlat_period_us; in osnoise_get_timerlat_period_us()
352 if (context->orig_timerlat_period_us != OSNOISE_TIME_INIT_VAL) in osnoise_get_timerlat_period_us()
353 return context->orig_timerlat_period_us; in osnoise_get_timerlat_period_us()
359 context->orig_timerlat_period_us = timerlat_period_us; in osnoise_get_timerlat_period_us()
367 * osnoise_set_timerlat_period_us - set "timerlat_period_us"
375 return -1; in osnoise_set_timerlat_period_us()
379 return -1; in osnoise_set_timerlat_period_us()
381 context->timerlat_period_us = timerlat_period_us; in osnoise_set_timerlat_period_us()
387 * osnoise_restore_timerlat_period_us - restore "timerlat_period_us"
393 if (context->orig_timerlat_period_us == OSNOISE_TIME_INIT_VAL) in osnoise_restore_timerlat_period_us()
396 if (context->orig_timerlat_period_us == context->timerlat_period_us) in osnoise_restore_timerlat_period_us()
399 retval = osnoise_write_ll_config("osnoise/timerlat_period_us", context->orig_timerlat_period_us); in osnoise_restore_timerlat_period_us()
404 context->timerlat_period_us = OSNOISE_TIME_INIT_VAL; in osnoise_restore_timerlat_period_us()
408 * osnoise_put_timerlat_period_us - restore original values and cleanup data
414 if (context->orig_timerlat_period_us == OSNOISE_TIME_INIT_VAL) in osnoise_put_timerlat_period_us()
417 context->orig_timerlat_period_us = OSNOISE_TIME_INIT_VAL; in osnoise_put_timerlat_period_us()
421 * osnoise_get_stop_us - read and save the original "stop_tracing_us"
428 if (context->stop_us != OSNOISE_OPTION_INIT_VAL) in osnoise_get_stop_us()
429 return context->stop_us; in osnoise_get_stop_us()
431 if (context->orig_stop_us != OSNOISE_OPTION_INIT_VAL) in osnoise_get_stop_us()
432 return context->orig_stop_us; in osnoise_get_stop_us()
438 context->orig_stop_us = stop_us; in osnoise_get_stop_us()
446 * osnoise_set_stop_us - set "stop_tracing_us"
454 return -1; in osnoise_set_stop_us()
458 return -1; in osnoise_set_stop_us()
460 context->stop_us = stop_us; in osnoise_set_stop_us()
466 * osnoise_restore_stop_us - restore the original "stop_tracing_us"
472 if (context->orig_stop_us == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_stop_us()
475 if (context->orig_stop_us == context->stop_us) in osnoise_restore_stop_us()
478 retval = osnoise_write_ll_config("osnoise/stop_tracing_us", context->orig_stop_us); in osnoise_restore_stop_us()
483 context->stop_us = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_stop_us()
487 * osnoise_put_stop_us - restore original values and cleanup data
493 if (context->orig_stop_us == OSNOISE_OPTION_INIT_VAL) in osnoise_put_stop_us()
496 context->orig_stop_us = OSNOISE_OPTION_INIT_VAL; in osnoise_put_stop_us()
500 * osnoise_get_stop_total_us - read and save the original "stop_tracing_total_us"
507 if (context->stop_total_us != OSNOISE_OPTION_INIT_VAL) in osnoise_get_stop_total_us()
508 return context->stop_total_us; in osnoise_get_stop_total_us()
510 if (context->orig_stop_total_us != OSNOISE_OPTION_INIT_VAL) in osnoise_get_stop_total_us()
511 return context->orig_stop_total_us; in osnoise_get_stop_total_us()
517 context->orig_stop_total_us = stop_total_us; in osnoise_get_stop_total_us()
525 * osnoise_set_stop_total_us - set "stop_tracing_total_us"
533 return -1; in osnoise_set_stop_total_us()
537 return -1; in osnoise_set_stop_total_us()
539 context->stop_total_us = stop_total_us; in osnoise_set_stop_total_us()
545 * osnoise_restore_stop_total_us - restore the original "stop_tracing_total_us"
551 if (context->orig_stop_total_us == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_stop_total_us()
554 if (context->orig_stop_total_us == context->stop_total_us) in osnoise_restore_stop_total_us()
558 context->orig_stop_total_us); in osnoise_restore_stop_total_us()
563 context->stop_total_us = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_stop_total_us()
567 * osnoise_put_stop_total_us - restore original values and cleanup data
573 if (context->orig_stop_total_us == OSNOISE_OPTION_INIT_VAL) in osnoise_put_stop_total_us()
576 context->orig_stop_total_us = OSNOISE_OPTION_INIT_VAL; in osnoise_put_stop_total_us()
580 * osnoise_get_print_stack - read and save the original "print_stack"
587 if (context->print_stack != OSNOISE_OPTION_INIT_VAL) in osnoise_get_print_stack()
588 return context->print_stack; in osnoise_get_print_stack()
590 if (context->orig_print_stack != OSNOISE_OPTION_INIT_VAL) in osnoise_get_print_stack()
591 return context->orig_print_stack; in osnoise_get_print_stack()
597 context->orig_print_stack = print_stack; in osnoise_get_print_stack()
605 * osnoise_set_print_stack - set "print_stack"
613 return -1; in osnoise_set_print_stack()
617 return -1; in osnoise_set_print_stack()
619 context->print_stack = print_stack; in osnoise_set_print_stack()
625 * osnoise_restore_print_stack - restore the original "print_stack"
631 if (context->orig_print_stack == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_print_stack()
634 if (context->orig_print_stack == context->print_stack) in osnoise_restore_print_stack()
637 retval = osnoise_write_ll_config("osnoise/print_stack", context->orig_print_stack); in osnoise_restore_print_stack()
642 context->print_stack = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_print_stack()
646 * osnoise_put_print_stack - restore original values and cleanup data
652 if (context->orig_print_stack == OSNOISE_OPTION_INIT_VAL) in osnoise_put_print_stack()
655 context->orig_print_stack = OSNOISE_OPTION_INIT_VAL; in osnoise_put_print_stack()
659 * osnoise_get_tracing_thresh - read and save the original "tracing_thresh"
666 if (context->tracing_thresh != OSNOISE_OPTION_INIT_VAL) in osnoise_get_tracing_thresh()
667 return context->tracing_thresh; in osnoise_get_tracing_thresh()
669 if (context->orig_tracing_thresh != OSNOISE_OPTION_INIT_VAL) in osnoise_get_tracing_thresh()
670 return context->orig_tracing_thresh; in osnoise_get_tracing_thresh()
676 context->orig_tracing_thresh = tracing_thresh; in osnoise_get_tracing_thresh()
684 * osnoise_set_tracing_thresh - set "tracing_thresh"
692 return -1; in osnoise_set_tracing_thresh()
696 return -1; in osnoise_set_tracing_thresh()
698 context->tracing_thresh = tracing_thresh; in osnoise_set_tracing_thresh()
704 * osnoise_restore_tracing_thresh - restore the original "tracing_thresh"
710 if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_tracing_thresh()
713 if (context->orig_tracing_thresh == context->tracing_thresh) in osnoise_restore_tracing_thresh()
716 retval = osnoise_write_ll_config("tracing_thresh", context->orig_tracing_thresh); in osnoise_restore_tracing_thresh()
721 context->tracing_thresh = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_tracing_thresh()
725 * osnoise_put_tracing_thresh - restore original values and cleanup data
731 if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL) in osnoise_put_tracing_thresh()
734 context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL; in osnoise_put_tracing_thresh()
785 if (context->opt_irq_disable != OSNOISE_OPTION_INIT_VAL) in osnoise_get_irq_disable()
786 return context->opt_irq_disable; in osnoise_get_irq_disable()
788 if (context->orig_opt_irq_disable != OSNOISE_OPTION_INIT_VAL) in osnoise_get_irq_disable()
789 return context->orig_opt_irq_disable; in osnoise_get_irq_disable()
791 context->orig_opt_irq_disable = osnoise_options_get_option("OSNOISE_IRQ_DISABLE"); in osnoise_get_irq_disable()
793 return context->orig_opt_irq_disable; in osnoise_get_irq_disable()
802 return -1; in osnoise_set_irq_disable()
809 return -1; in osnoise_set_irq_disable()
811 context->opt_irq_disable = onoff; in osnoise_set_irq_disable()
820 if (context->orig_opt_irq_disable == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_irq_disable()
823 if (context->orig_opt_irq_disable == context->opt_irq_disable) in osnoise_restore_irq_disable()
826 retval = osnoise_options_set_option("OSNOISE_IRQ_DISABLE", context->orig_opt_irq_disable); in osnoise_restore_irq_disable()
831 context->orig_opt_irq_disable = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_irq_disable()
838 if (context->orig_opt_irq_disable == OSNOISE_OPTION_INIT_VAL) in osnoise_put_irq_disable()
841 context->orig_opt_irq_disable = OSNOISE_OPTION_INIT_VAL; in osnoise_put_irq_disable()
846 if (context->opt_workload != OSNOISE_OPTION_INIT_VAL) in osnoise_get_workload()
847 return context->opt_workload; in osnoise_get_workload()
849 if (context->orig_opt_workload != OSNOISE_OPTION_INIT_VAL) in osnoise_get_workload()
850 return context->orig_opt_workload; in osnoise_get_workload()
852 context->orig_opt_workload = osnoise_options_get_option("OSNOISE_WORKLOAD"); in osnoise_get_workload()
854 return context->orig_opt_workload; in osnoise_get_workload()
863 return -1; in osnoise_set_workload()
870 return -1; in osnoise_set_workload()
872 context->opt_workload = onoff; in osnoise_set_workload()
881 if (context->orig_opt_workload == OSNOISE_OPTION_INIT_VAL) in osnoise_restore_workload()
884 if (context->orig_opt_workload == context->opt_workload) in osnoise_restore_workload()
887 retval = osnoise_options_set_option("OSNOISE_WORKLOAD", context->orig_opt_workload); in osnoise_restore_workload()
892 context->orig_opt_workload = OSNOISE_OPTION_INIT_VAL; in osnoise_restore_workload()
899 if (context->orig_opt_workload == OSNOISE_OPTION_INIT_VAL) in osnoise_put_workload()
902 context->orig_opt_workload = OSNOISE_OPTION_INIT_VAL; in osnoise_put_workload()
906 * enable_osnoise - enable osnoise tracer in the trace_instance
910 return enable_tracer_by_name(trace->inst, "osnoise"); in enable_osnoise()
914 * enable_timerlat - enable timerlat tracer in the trace_instance
918 return enable_tracer_by_name(trace->inst, "timerlat"); in enable_timerlat()
927 * osnoise_get_context - increase the usage of a context and return it
933 if (context->flags & FLAG_CONTEXT_DELETED) { in osnoise_get_context()
934 ret = -1; in osnoise_get_context()
936 context->ref++; in osnoise_get_context()
944 * osnoise_context_alloc - alloc an osnoise_context
947 * It is used to set and restore the config.
957 context->orig_stop_us = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
958 context->stop_us = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
960 context->orig_stop_total_us = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
961 context->stop_total_us = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
963 context->orig_print_stack = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
964 context->print_stack = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
966 context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
967 context->tracing_thresh = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
969 context->orig_opt_irq_disable = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
970 context->opt_irq_disable = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
972 context->orig_opt_workload = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
973 context->opt_workload = OSNOISE_OPTION_INIT_VAL; in osnoise_context_alloc()
981 * osnoise_put_context - put the osnoise_put_context
988 if (--context->ref < 1) in osnoise_put_context()
989 context->flags |= FLAG_CONTEXT_DELETED; in osnoise_put_context()
991 if (!(context->flags & FLAG_CONTEXT_DELETED)) in osnoise_put_context()
1008 * osnoise_destroy_tool - disable trace, restore configs and free data
1010 void osnoise_destroy_tool(struct osnoise_tool *top) in osnoise_destroy_tool() argument
1012 if (!top) in osnoise_destroy_tool()
1015 trace_instance_destroy(&top->trace); in osnoise_destroy_tool()
1017 if (top->context) in osnoise_destroy_tool()
1018 osnoise_put_context(top->context); in osnoise_destroy_tool()
1020 free(top); in osnoise_destroy_tool()
1024 * osnoise_init_tool - init an osnoise tool
1031 struct osnoise_tool *top; in osnoise_init_tool() local
1034 top = calloc(1, sizeof(*top)); in osnoise_init_tool()
1035 if (!top) in osnoise_init_tool()
1038 top->context = osnoise_context_alloc(); in osnoise_init_tool()
1039 if (!top->context) in osnoise_init_tool()
1042 retval = trace_instance_init(&top->trace, tool_name); in osnoise_init_tool()
1046 return top; in osnoise_init_tool()
1048 osnoise_destroy_tool(top); in osnoise_init_tool()
1053 * osnoise_init_trace_tool - init a tracer instance to trace osnoise events
1064 retval = tracefs_event_enable(trace->trace.inst, "osnoise", NULL); in osnoise_init_trace_tool()
1070 retval = enable_tracer_by_name(trace->trace.inst, tracer); in osnoise_init_trace_tool()
1093 " top - prints the summary from osnoise tracer", in osnoise_usage()
1094 " hist - prints a histogram of osnoise samples", in osnoise_usage()
1096 "if no MODE is given, the top mode is called, passing the arguments", in osnoise_usage()
1119 if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { in osnoise_main()
1121 } else if (strncmp(argv[1], "-", 1) == 0) { in osnoise_main()
1125 } else if (strcmp(argv[1], "top") == 0) { in osnoise_main()
1126 osnoise_top_main(argc-1, &argv[1]); in osnoise_main()
1129 osnoise_hist_main(argc-1, &argv[1]); in osnoise_main()