Lines Matching refs:context
24 char *osnoise_get_cpus(struct osnoise_context *context) in osnoise_get_cpus() argument
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()
48 int osnoise_set_cpus(struct osnoise_context *context, char *cpus) in osnoise_set_cpus() argument
50 char *orig_cpus = osnoise_get_cpus(context); in osnoise_set_cpus()
57 context->curr_cpus = strdup(cpus); in osnoise_set_cpus()
58 if (!context->curr_cpus) 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()
82 void osnoise_restore_cpus(struct osnoise_context *context) in osnoise_restore_cpus() argument
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()
110 void osnoise_put_cpus(struct osnoise_context *context) in osnoise_put_cpus() argument
112 osnoise_restore_cpus(context); in osnoise_put_cpus()
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()
168 unsigned long long osnoise_get_runtime(struct osnoise_context *context) in osnoise_get_runtime() argument
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()
194 unsigned long long osnoise_get_period(struct osnoise_context *context) in osnoise_get_period() argument
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()
215 static int __osnoise_write_runtime(struct osnoise_context *context, in __osnoise_write_runtime() argument
220 if (context->orig_runtime_us == OSNOISE_TIME_INIT_VAL) in __osnoise_write_runtime()
227 context->runtime_us = runtime; in __osnoise_write_runtime()
231 static int __osnoise_write_period(struct osnoise_context *context, in __osnoise_write_period() argument
236 if (context->orig_period_us == OSNOISE_TIME_INIT_VAL) in __osnoise_write_period()
243 context->period_us = period; in __osnoise_write_period()
254 int osnoise_set_runtime_period(struct osnoise_context *context, in osnoise_set_runtime_period() argument
265 curr_runtime_us = osnoise_get_runtime(context); in osnoise_set_runtime_period()
266 curr_period_us = osnoise_get_period(context); in osnoise_set_runtime_period()
275 return __osnoise_write_runtime(context, runtime); in osnoise_set_runtime_period()
279 return __osnoise_write_period(context, period); in osnoise_set_runtime_period()
283 retval = __osnoise_write_period(context, period); in osnoise_set_runtime_period()
286 retval = __osnoise_write_runtime(context, runtime); in osnoise_set_runtime_period()
290 retval = __osnoise_write_runtime(context, runtime); in osnoise_set_runtime_period()
293 retval = __osnoise_write_period(context, period); in osnoise_set_runtime_period()
304 void osnoise_restore_runtime_period(struct osnoise_context *context) in osnoise_restore_runtime_period() argument
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()
318 retval = osnoise_set_runtime_period(context, orig_runtime, orig_period); 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()
330 void osnoise_put_runtime_period(struct osnoise_context *context) in osnoise_put_runtime_period() argument
332 osnoise_restore_runtime_period(context); in osnoise_put_runtime_period()
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()
345 osnoise_get_timerlat_period_us(struct osnoise_context *context) in osnoise_get_timerlat_period_us() argument
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()
369 int osnoise_set_timerlat_period_us(struct osnoise_context *context, long long timerlat_period_us) in osnoise_set_timerlat_period_us() argument
371 long long curr_timerlat_period_us = osnoise_get_timerlat_period_us(context); in osnoise_set_timerlat_period_us()
381 context->timerlat_period_us = timerlat_period_us; in osnoise_set_timerlat_period_us()
389 void osnoise_restore_timerlat_period_us(struct osnoise_context *context) in osnoise_restore_timerlat_period_us() argument
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()
410 void osnoise_put_timerlat_period_us(struct osnoise_context *context) in osnoise_put_timerlat_period_us() argument
412 osnoise_restore_timerlat_period_us(context); in osnoise_put_timerlat_period_us()
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()
424 osnoise_get_stop_us(struct osnoise_context *context) in osnoise_get_stop_us() argument
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()
448 int osnoise_set_stop_us(struct osnoise_context *context, long long stop_us) in osnoise_set_stop_us() argument
450 long long curr_stop_us = osnoise_get_stop_us(context); in osnoise_set_stop_us()
460 context->stop_us = stop_us; in osnoise_set_stop_us()
468 void osnoise_restore_stop_us(struct osnoise_context *context) in osnoise_restore_stop_us() argument
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()
489 void osnoise_put_stop_us(struct osnoise_context *context) in osnoise_put_stop_us() argument
491 osnoise_restore_stop_us(context); in osnoise_put_stop_us()
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()
503 osnoise_get_stop_total_us(struct osnoise_context *context) in osnoise_get_stop_total_us() argument
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()
527 int osnoise_set_stop_total_us(struct osnoise_context *context, long long stop_total_us) in osnoise_set_stop_total_us() argument
529 long long curr_stop_total_us = osnoise_get_stop_total_us(context); in osnoise_set_stop_total_us()
539 context->stop_total_us = stop_total_us; in osnoise_set_stop_total_us()
547 void osnoise_restore_stop_total_us(struct osnoise_context *context) in osnoise_restore_stop_total_us() argument
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()
569 void osnoise_put_stop_total_us(struct osnoise_context *context) in osnoise_put_stop_total_us() argument
571 osnoise_restore_stop_total_us(context); in osnoise_put_stop_total_us()
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()
583 osnoise_get_print_stack(struct osnoise_context *context) in osnoise_get_print_stack() argument
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()
607 int osnoise_set_print_stack(struct osnoise_context *context, long long print_stack) in osnoise_set_print_stack() argument
609 long long curr_print_stack = osnoise_get_print_stack(context); in osnoise_set_print_stack()
619 context->print_stack = print_stack; in osnoise_set_print_stack()
627 void osnoise_restore_print_stack(struct osnoise_context *context) in osnoise_restore_print_stack() argument
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()
648 void osnoise_put_print_stack(struct osnoise_context *context) in osnoise_put_print_stack() argument
650 osnoise_restore_print_stack(context); in osnoise_put_print_stack()
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()
662 osnoise_get_tracing_thresh(struct osnoise_context *context) in osnoise_get_tracing_thresh() argument
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()
686 int osnoise_set_tracing_thresh(struct osnoise_context *context, long long tracing_thresh) in osnoise_set_tracing_thresh() argument
688 long long curr_tracing_thresh = osnoise_get_tracing_thresh(context); in osnoise_set_tracing_thresh()
698 context->tracing_thresh = tracing_thresh; in osnoise_set_tracing_thresh()
706 void osnoise_restore_tracing_thresh(struct osnoise_context *context) in osnoise_restore_tracing_thresh() argument
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()
727 void osnoise_put_tracing_thresh(struct osnoise_context *context) in osnoise_put_tracing_thresh() argument
729 osnoise_restore_tracing_thresh(context); in osnoise_put_tracing_thresh()
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()
783 static int osnoise_get_irq_disable(struct osnoise_context *context) in osnoise_get_irq_disable() argument
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()
796 int osnoise_set_irq_disable(struct osnoise_context *context, bool onoff) in osnoise_set_irq_disable() argument
798 int opt_irq_disable = osnoise_get_irq_disable(context); in osnoise_set_irq_disable()
811 context->opt_irq_disable = onoff; in osnoise_set_irq_disable()
816 static void osnoise_restore_irq_disable(struct osnoise_context *context) in osnoise_restore_irq_disable() argument
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()
834 static void osnoise_put_irq_disable(struct osnoise_context *context) in osnoise_put_irq_disable() argument
836 osnoise_restore_irq_disable(context); in osnoise_put_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()
844 static int osnoise_get_workload(struct osnoise_context *context) in osnoise_get_workload() argument
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()
857 int osnoise_set_workload(struct osnoise_context *context, bool onoff) in osnoise_set_workload() argument
859 int opt_workload = osnoise_get_workload(context); in osnoise_set_workload()
872 context->opt_workload = onoff; in osnoise_set_workload()
877 static void osnoise_restore_workload(struct osnoise_context *context) in osnoise_restore_workload() argument
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()
895 static void osnoise_put_workload(struct osnoise_context *context) in osnoise_put_workload() argument
897 osnoise_restore_workload(context); in osnoise_put_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()
929 int osnoise_get_context(struct osnoise_context *context) in osnoise_get_context() argument
933 if (context->flags & FLAG_CONTEXT_DELETED) { in osnoise_get_context()
936 context->ref++; in osnoise_get_context()
951 struct osnoise_context *context; in osnoise_context_alloc() local
953 context = calloc(1, sizeof(*context)); in osnoise_context_alloc()
954 if (!context) in osnoise_context_alloc()
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()
975 osnoise_get_context(context); in osnoise_context_alloc()
977 return context; in osnoise_context_alloc()
986 void osnoise_put_context(struct osnoise_context *context) in osnoise_put_context() argument
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()
994 osnoise_put_cpus(context); in osnoise_put_context()
995 osnoise_put_runtime_period(context); in osnoise_put_context()
996 osnoise_put_stop_us(context); in osnoise_put_context()
997 osnoise_put_stop_total_us(context); in osnoise_put_context()
998 osnoise_put_timerlat_period_us(context); in osnoise_put_context()
999 osnoise_put_print_stack(context); in osnoise_put_context()
1000 osnoise_put_tracing_thresh(context); in osnoise_put_context()
1001 osnoise_put_irq_disable(context); in osnoise_put_context()
1002 osnoise_put_workload(context); in osnoise_put_context()
1004 free(context); in osnoise_put_context()
1017 if (top->context) in osnoise_destroy_tool()
1018 osnoise_put_context(top->context); in osnoise_destroy_tool()
1038 top->context = osnoise_context_alloc(); in osnoise_init_tool()
1039 if (!top->context) in osnoise_init_tool()