Lines Matching refs:ftrace

223 static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)  in reset_tracing_options()
235 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) in reset_tracing_files()
256 reset_tracing_options(ftrace); in reset_tracing_files()
260 static int set_tracing_pid(struct perf_ftrace *ftrace) in set_tracing_pid() argument
265 if (target__has_cpu(&ftrace->target)) in set_tracing_pid()
268 for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) { in set_tracing_pid()
270 perf_thread_map__pid(ftrace->evlist->core.threads, i)); in set_tracing_pid()
302 static int set_tracing_cpu(struct perf_ftrace *ftrace) in set_tracing_cpu() argument
304 struct perf_cpu_map *cpumap = ftrace->evlist->core.user_requested_cpus; in set_tracing_cpu()
306 if (!target__has_cpu(&ftrace->target)) in set_tracing_cpu()
312 static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace) in set_tracing_func_stack_trace() argument
314 if (!ftrace->func_stack_trace) in set_tracing_func_stack_trace()
323 static int set_tracing_func_irqinfo(struct perf_ftrace *ftrace) in set_tracing_func_irqinfo() argument
325 if (!ftrace->func_irq_info) in set_tracing_func_irqinfo()
356 static int set_tracing_filters(struct perf_ftrace *ftrace) in set_tracing_filters() argument
360 ret = __set_tracing_filter("set_ftrace_filter", &ftrace->filters); in set_tracing_filters()
364 ret = __set_tracing_filter("set_ftrace_notrace", &ftrace->notrace); in set_tracing_filters()
368 ret = __set_tracing_filter("set_graph_function", &ftrace->graph_funcs); in set_tracing_filters()
373 __set_tracing_filter("set_graph_notrace", &ftrace->nograph_funcs); in set_tracing_filters()
386 static int set_tracing_depth(struct perf_ftrace *ftrace) in set_tracing_depth() argument
388 if (ftrace->graph_depth == 0) in set_tracing_depth()
391 if (ftrace->graph_depth < 0) { in set_tracing_depth()
392 pr_err("invalid graph depth: %d\n", ftrace->graph_depth); in set_tracing_depth()
396 if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0) in set_tracing_depth()
402 static int set_tracing_percpu_buffer_size(struct perf_ftrace *ftrace) in set_tracing_percpu_buffer_size() argument
406 if (ftrace->percpu_buffer_size == 0) in set_tracing_percpu_buffer_size()
410 ftrace->percpu_buffer_size / 1024); in set_tracing_percpu_buffer_size()
417 static int set_tracing_trace_inherit(struct perf_ftrace *ftrace) in set_tracing_trace_inherit() argument
419 if (!ftrace->inherit) in set_tracing_trace_inherit()
428 static int set_tracing_sleep_time(struct perf_ftrace *ftrace) in set_tracing_sleep_time() argument
430 if (!ftrace->graph_nosleep_time) in set_tracing_sleep_time()
439 static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace) in set_tracing_funcgraph_irqs() argument
441 if (!ftrace->graph_noirqs) in set_tracing_funcgraph_irqs()
450 static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) in set_tracing_funcgraph_verbose() argument
452 if (!ftrace->graph_verbose) in set_tracing_funcgraph_verbose()
467 static int set_tracing_thresh(struct perf_ftrace *ftrace) in set_tracing_thresh() argument
471 if (ftrace->graph_thresh == 0) in set_tracing_thresh()
474 ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh); in set_tracing_thresh()
481 static int set_tracing_options(struct perf_ftrace *ftrace) in set_tracing_options() argument
483 if (set_tracing_pid(ftrace) < 0) { in set_tracing_options()
488 if (set_tracing_cpu(ftrace) < 0) { in set_tracing_options()
493 if (set_tracing_func_stack_trace(ftrace) < 0) { in set_tracing_options()
498 if (set_tracing_func_irqinfo(ftrace) < 0) { in set_tracing_options()
503 if (set_tracing_filters(ftrace) < 0) { in set_tracing_options()
508 if (set_tracing_depth(ftrace) < 0) { in set_tracing_options()
513 if (set_tracing_percpu_buffer_size(ftrace) < 0) { in set_tracing_options()
518 if (set_tracing_trace_inherit(ftrace) < 0) { in set_tracing_options()
523 if (set_tracing_sleep_time(ftrace) < 0) { in set_tracing_options()
528 if (set_tracing_funcgraph_irqs(ftrace) < 0) { in set_tracing_options()
533 if (set_tracing_funcgraph_verbose(ftrace) < 0) { in set_tracing_options()
538 if (set_tracing_thresh(ftrace) < 0) { in set_tracing_options()
546 static void select_tracer(struct perf_ftrace *ftrace) in select_tracer() argument
548 bool graph = !list_empty(&ftrace->graph_funcs) || in select_tracer()
549 !list_empty(&ftrace->nograph_funcs); in select_tracer()
550 bool func = !list_empty(&ftrace->filters) || in select_tracer()
551 !list_empty(&ftrace->notrace); in select_tracer()
555 ftrace->tracer = "function_graph"; in select_tracer()
557 ftrace->tracer = "function"; in select_tracer()
560 pr_debug("%s tracer is used\n", ftrace->tracer); in select_tracer()
563 static int __cmd_ftrace(struct perf_ftrace *ftrace) in __cmd_ftrace() argument
584 select_tracer(ftrace); in __cmd_ftrace()
586 if (reset_tracing_files(ftrace) < 0) { in __cmd_ftrace()
595 if (set_tracing_options(ftrace) < 0) in __cmd_ftrace()
598 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { in __cmd_ftrace()
599 pr_err("failed to set current_tracer to %s\n", ftrace->tracer); in __cmd_ftrace()
626 if (!ftrace->target.initial_delay) { in __cmd_ftrace()
633 evlist__start_workload(ftrace->evlist); in __cmd_ftrace()
635 if (ftrace->target.initial_delay > 0) { in __cmd_ftrace()
636 usleep(ftrace->target.initial_delay * 1000); in __cmd_ftrace()
680 reset_tracing_files(ftrace); in __cmd_ftrace()
799 static int prepare_func_latency(struct perf_ftrace *ftrace) in prepare_func_latency() argument
804 if (ftrace->target.use_bpf) in prepare_func_latency()
805 return perf_ftrace__latency_prepare_bpf(ftrace); in prepare_func_latency()
807 if (reset_tracing_files(ftrace) < 0) { in prepare_func_latency()
816 if (set_tracing_options(ftrace) < 0) in prepare_func_latency()
839 static int start_func_latency(struct perf_ftrace *ftrace) in start_func_latency() argument
841 if (ftrace->target.use_bpf) in start_func_latency()
842 return perf_ftrace__latency_start_bpf(ftrace); in start_func_latency()
852 static int stop_func_latency(struct perf_ftrace *ftrace) in stop_func_latency() argument
854 if (ftrace->target.use_bpf) in stop_func_latency()
855 return perf_ftrace__latency_stop_bpf(ftrace); in stop_func_latency()
861 static int read_func_latency(struct perf_ftrace *ftrace, int buckets[]) in read_func_latency() argument
863 if (ftrace->target.use_bpf) in read_func_latency()
864 return perf_ftrace__latency_read_bpf(ftrace, buckets); in read_func_latency()
869 static int cleanup_func_latency(struct perf_ftrace *ftrace) in cleanup_func_latency() argument
871 if (ftrace->target.use_bpf) in cleanup_func_latency()
872 return perf_ftrace__latency_cleanup_bpf(ftrace); in cleanup_func_latency()
874 reset_tracing_files(ftrace); in cleanup_func_latency()
878 static int __cmd_latency(struct perf_ftrace *ftrace) in __cmd_latency() argument
900 trace_fd = prepare_func_latency(ftrace); in __cmd_latency()
907 if (start_func_latency(ftrace) < 0) in __cmd_latency()
910 evlist__start_workload(ftrace->evlist); in __cmd_latency()
922 make_histogram(buckets, buf, n, line, ftrace->use_nsec); in __cmd_latency()
926 stop_func_latency(ftrace); in __cmd_latency()
935 while (!ftrace->target.use_bpf) { in __cmd_latency()
939 make_histogram(buckets, buf, n, line, ftrace->use_nsec); in __cmd_latency()
942 read_func_latency(ftrace, buckets); in __cmd_latency()
944 display_histogram(buckets, ftrace->use_nsec); in __cmd_latency()
948 cleanup_func_latency(ftrace); in __cmd_latency()
955 struct perf_ftrace *ftrace = cb; in perf_ftrace_config() local
965 ftrace->tracer = value; in perf_ftrace_config()
1074 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value; in parse_func_tracer_opts() local
1076 { .name = "call-graph", .value_ptr = &ftrace->func_stack_trace }, in parse_func_tracer_opts()
1077 { .name = "irq-info", .value_ptr = &ftrace->func_irq_info }, in parse_func_tracer_opts()
1095 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value; in parse_graph_tracer_opts() local
1097 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, in parse_graph_tracer_opts()
1098 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs }, in parse_graph_tracer_opts()
1099 { .name = "verbose", .value_ptr = &ftrace->graph_verbose }, in parse_graph_tracer_opts()
1100 { .name = "thresh", .value_ptr = &ftrace->graph_thresh }, in parse_graph_tracer_opts()
1101 { .name = "depth", .value_ptr = &ftrace->graph_depth }, in parse_graph_tracer_opts()
1125 struct perf_ftrace ftrace = { in cmd_ftrace() local
1130 OPT_STRING('p', "pid", &ftrace.target.pid, "pid", in cmd_ftrace()
1133 OPT_STRING(0, "tid", &ftrace.target.tid, "tid", in cmd_ftrace()
1137 OPT_BOOLEAN('a', "all-cpus", &ftrace.target.system_wide, in cmd_ftrace()
1139 OPT_STRING('C', "cpu", &ftrace.target.cpu_list, "cpu", in cmd_ftrace()
1144 OPT_STRING('t', "tracer", &ftrace.tracer, "tracer", in cmd_ftrace()
1149 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func", in cmd_ftrace()
1152 OPT_CALLBACK('N', "notrace-funcs", &ftrace.notrace, "func", in cmd_ftrace()
1154 OPT_CALLBACK(0, "func-opts", &ftrace, "options", in cmd_ftrace()
1157 OPT_CALLBACK('G', "graph-funcs", &ftrace.graph_funcs, "func", in cmd_ftrace()
1160 OPT_CALLBACK('g', "nograph-funcs", &ftrace.nograph_funcs, "func", in cmd_ftrace()
1162 OPT_CALLBACK(0, "graph-opts", &ftrace, "options", in cmd_ftrace()
1165 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", in cmd_ftrace()
1167 OPT_BOOLEAN(0, "inherit", &ftrace.inherit, in cmd_ftrace()
1169 OPT_INTEGER('D', "delay", &ftrace.target.initial_delay, in cmd_ftrace()
1174 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func", in cmd_ftrace()
1177 OPT_BOOLEAN('b', "use-bpf", &ftrace.target.use_bpf, in cmd_ftrace()
1180 OPT_BOOLEAN('n', "use-nsec", &ftrace.use_nsec, in cmd_ftrace()
1195 INIT_LIST_HEAD(&ftrace.filters); in cmd_ftrace()
1196 INIT_LIST_HEAD(&ftrace.notrace); in cmd_ftrace()
1197 INIT_LIST_HEAD(&ftrace.graph_funcs); in cmd_ftrace()
1198 INIT_LIST_HEAD(&ftrace.nograph_funcs); in cmd_ftrace()
1205 ret = perf_config(perf_ftrace_config, &ftrace); in cmd_ftrace()
1234 if (!argc && target__none(&ftrace.target)) in cmd_ftrace()
1235 ftrace.target.system_wide = true; in cmd_ftrace()
1242 if (list_empty(&ftrace.filters)) { in cmd_ftrace()
1257 ret = target__validate(&ftrace.target); in cmd_ftrace()
1261 target__strerror(&ftrace.target, ret, errbuf, 512); in cmd_ftrace()
1266 ftrace.evlist = evlist__new(); in cmd_ftrace()
1267 if (ftrace.evlist == NULL) { in cmd_ftrace()
1272 ret = evlist__create_maps(ftrace.evlist, &ftrace.target); in cmd_ftrace()
1277 ret = evlist__prepare_workload(ftrace.evlist, &ftrace.target, in cmd_ftrace()
1284 ret = cmd_func(&ftrace); in cmd_ftrace()
1287 evlist__delete(ftrace.evlist); in cmd_ftrace()
1290 delete_filter_func(&ftrace.filters); in cmd_ftrace()
1291 delete_filter_func(&ftrace.notrace); in cmd_ftrace()
1292 delete_filter_func(&ftrace.graph_funcs); in cmd_ftrace()
1293 delete_filter_func(&ftrace.nograph_funcs); in cmd_ftrace()