Lines Matching +full:ftrace +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0-only
3 * builtin-ftrace.c
25 #include <subcmd/parse-options.h>
36 #include "util/ftrace.h"
39 #include "util/parse-sublevel-options.h"
62 workload_exec_errno = info->si_value.sival_int; in ftrace__workload_exec_failed_signal()
76 pr_err("ftrace only works for %s!\n", in check_ftrace_capable()
104 int fd, ret = -1; in __write_tracing_file()
105 ssize_t size = strlen(val); in __write_tracing_file() local
113 return -1; in __write_tracing_file()
135 val_copy[size] = '\n'; in __write_tracing_file()
137 if (write(fd, val_copy, size + 1) == size + 1) in __write_tracing_file()
166 int ret = -1; in read_tracing_file_to_stdout()
171 return -1; in read_tracing_file_to_stdout()
213 return -1; in read_tracing_file_by_line()
220 return -1; in read_tracing_file_by_line()
223 while (getline(&line, &len, fp) != -1) { in read_tracing_file_by_line()
241 return -1; in write_tracing_file_int()
252 return -1; in write_tracing_option_file()
262 static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) in reset_tracing_options()
264 write_tracing_option_file("function-fork", "0"); in reset_tracing_options()
266 write_tracing_option_file("sleep-time", "1"); in reset_tracing_options()
267 write_tracing_option_file("funcgraph-irqs", "1"); in reset_tracing_options()
268 write_tracing_option_file("funcgraph-proc", "0"); in reset_tracing_options()
269 write_tracing_option_file("funcgraph-abstime", "0"); in reset_tracing_options()
270 write_tracing_option_file("funcgraph-tail", "0"); in reset_tracing_options()
271 write_tracing_option_file("latency-format", "0"); in reset_tracing_options()
272 write_tracing_option_file("irq-info", "0"); in reset_tracing_options()
275 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) in reset_tracing_files()
278 return -1; in reset_tracing_files()
281 return -1; in reset_tracing_files()
284 return -1; in reset_tracing_files()
287 return -1; in reset_tracing_files()
290 return -1; in reset_tracing_files()
293 return -1; in reset_tracing_files()
296 reset_tracing_options(ftrace); in reset_tracing_files()
300 static int set_tracing_pid(struct perf_ftrace *ftrace) in set_tracing_pid() argument
305 if (target__has_cpu(&ftrace->target)) in set_tracing_pid()
308 for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) { in set_tracing_pid()
310 perf_thread_map__pid(ftrace->evlist->core.threads, i)); in set_tracing_pid()
312 return -1; in set_tracing_pid()
324 last_cpu = perf_cpu_map__cpu(cpumap, perf_cpu_map__nr(cpumap) - 1).cpu; in set_tracing_cpumask()
331 return -1; in set_tracing_cpumask()
342 static int set_tracing_cpu(struct perf_ftrace *ftrace) in set_tracing_cpu() argument
344 struct perf_cpu_map *cpumap = ftrace->evlist->core.user_requested_cpus; in set_tracing_cpu()
346 if (!target__has_cpu(&ftrace->target)) in set_tracing_cpu()
352 static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace) in set_tracing_func_stack_trace() argument
354 if (!ftrace->func_stack_trace) in set_tracing_func_stack_trace()
358 return -1; in set_tracing_func_stack_trace()
363 static int set_tracing_func_irqinfo(struct perf_ftrace *ftrace) in set_tracing_func_irqinfo() argument
365 if (!ftrace->func_irq_info) in set_tracing_func_irqinfo()
368 if (write_tracing_option_file("irq-info", "1") < 0) in set_tracing_func_irqinfo()
369 return -1; in set_tracing_func_irqinfo()
389 if (append_tracing_file(filter_file, pos->name) < 0) in __set_tracing_filter()
390 return -1; in __set_tracing_filter()
396 static int set_tracing_filters(struct perf_ftrace *ftrace) in set_tracing_filters() argument
400 ret = __set_tracing_filter("set_ftrace_filter", &ftrace->filters); in set_tracing_filters()
404 ret = __set_tracing_filter("set_ftrace_notrace", &ftrace->notrace); in set_tracing_filters()
408 ret = __set_tracing_filter("set_graph_function", &ftrace->graph_funcs); in set_tracing_filters()
413 __set_tracing_filter("set_graph_notrace", &ftrace->nograph_funcs); in set_tracing_filters()
426 static int set_tracing_depth(struct perf_ftrace *ftrace) in set_tracing_depth() argument
428 if (ftrace->graph_depth == 0) in set_tracing_depth()
431 if (ftrace->graph_depth < 0) { in set_tracing_depth()
432 pr_err("invalid graph depth: %d\n", ftrace->graph_depth); in set_tracing_depth()
433 return -1; in set_tracing_depth()
436 if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0) in set_tracing_depth()
437 return -1; in set_tracing_depth()
442 static int set_tracing_percpu_buffer_size(struct perf_ftrace *ftrace) in set_tracing_percpu_buffer_size() argument
446 if (ftrace->percpu_buffer_size == 0) in set_tracing_percpu_buffer_size()
450 ftrace->percpu_buffer_size / 1024); in set_tracing_percpu_buffer_size()
457 static int set_tracing_trace_inherit(struct perf_ftrace *ftrace) in set_tracing_trace_inherit() argument
459 if (!ftrace->inherit) in set_tracing_trace_inherit()
462 if (write_tracing_option_file("function-fork", "1") < 0) in set_tracing_trace_inherit()
463 return -1; in set_tracing_trace_inherit()
468 static int set_tracing_sleep_time(struct perf_ftrace *ftrace) in set_tracing_sleep_time() argument
470 if (!ftrace->graph_nosleep_time) in set_tracing_sleep_time()
473 if (write_tracing_option_file("sleep-time", "0") < 0) in set_tracing_sleep_time()
474 return -1; in set_tracing_sleep_time()
479 static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace) in set_tracing_funcgraph_irqs() argument
481 if (!ftrace->graph_noirqs) in set_tracing_funcgraph_irqs()
484 if (write_tracing_option_file("funcgraph-irqs", "0") < 0) in set_tracing_funcgraph_irqs()
485 return -1; in set_tracing_funcgraph_irqs()
490 static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace) in set_tracing_funcgraph_verbose() argument
492 if (!ftrace->graph_verbose) in set_tracing_funcgraph_verbose()
495 if (write_tracing_option_file("funcgraph-proc", "1") < 0) in set_tracing_funcgraph_verbose()
496 return -1; in set_tracing_funcgraph_verbose()
498 if (write_tracing_option_file("funcgraph-abstime", "1") < 0) in set_tracing_funcgraph_verbose()
499 return -1; in set_tracing_funcgraph_verbose()
501 if (write_tracing_option_file("latency-format", "1") < 0) in set_tracing_funcgraph_verbose()
502 return -1; in set_tracing_funcgraph_verbose()
507 static int set_tracing_funcgraph_tail(struct perf_ftrace *ftrace) in set_tracing_funcgraph_tail() argument
509 if (!ftrace->graph_tail) in set_tracing_funcgraph_tail()
512 if (write_tracing_option_file("funcgraph-tail", "1") < 0) in set_tracing_funcgraph_tail()
513 return -1; in set_tracing_funcgraph_tail()
518 static int set_tracing_thresh(struct perf_ftrace *ftrace) in set_tracing_thresh() argument
522 if (ftrace->graph_thresh == 0) in set_tracing_thresh()
525 ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh); in set_tracing_thresh()
532 static int set_tracing_options(struct perf_ftrace *ftrace) in set_tracing_options() argument
534 if (set_tracing_pid(ftrace) < 0) { in set_tracing_options()
535 pr_err("failed to set ftrace pid\n"); in set_tracing_options()
536 return -1; in set_tracing_options()
539 if (set_tracing_cpu(ftrace) < 0) { in set_tracing_options()
541 return -1; in set_tracing_options()
544 if (set_tracing_func_stack_trace(ftrace) < 0) { in set_tracing_options()
546 return -1; in set_tracing_options()
549 if (set_tracing_func_irqinfo(ftrace) < 0) { in set_tracing_options()
550 pr_err("failed to set tracing option irq-info\n"); in set_tracing_options()
551 return -1; in set_tracing_options()
554 if (set_tracing_filters(ftrace) < 0) { in set_tracing_options()
556 return -1; in set_tracing_options()
559 if (set_tracing_depth(ftrace) < 0) { in set_tracing_options()
561 return -1; in set_tracing_options()
564 if (set_tracing_percpu_buffer_size(ftrace) < 0) { in set_tracing_options()
565 pr_err("failed to set tracing per-cpu buffer size\n"); in set_tracing_options()
566 return -1; in set_tracing_options()
569 if (set_tracing_trace_inherit(ftrace) < 0) { in set_tracing_options()
570 pr_err("failed to set tracing option function-fork\n"); in set_tracing_options()
571 return -1; in set_tracing_options()
574 if (set_tracing_sleep_time(ftrace) < 0) { in set_tracing_options()
575 pr_err("failed to set tracing option sleep-time\n"); in set_tracing_options()
576 return -1; in set_tracing_options()
579 if (set_tracing_funcgraph_irqs(ftrace) < 0) { in set_tracing_options()
580 pr_err("failed to set tracing option funcgraph-irqs\n"); in set_tracing_options()
581 return -1; in set_tracing_options()
584 if (set_tracing_funcgraph_verbose(ftrace) < 0) { in set_tracing_options()
585 pr_err("failed to set tracing option funcgraph-proc/funcgraph-abstime\n"); in set_tracing_options()
586 return -1; in set_tracing_options()
589 if (set_tracing_thresh(ftrace) < 0) { in set_tracing_options()
591 return -1; in set_tracing_options()
594 if (set_tracing_funcgraph_tail(ftrace) < 0) { in set_tracing_options()
595 pr_err("failed to set tracing option funcgraph-tail\n"); in set_tracing_options()
596 return -1; in set_tracing_options()
602 static void select_tracer(struct perf_ftrace *ftrace) in select_tracer() argument
604 bool graph = !list_empty(&ftrace->graph_funcs) || in select_tracer()
605 !list_empty(&ftrace->nograph_funcs); in select_tracer()
606 bool func = !list_empty(&ftrace->filters) || in select_tracer()
607 !list_empty(&ftrace->notrace); in select_tracer()
611 ftrace->tracer = "function_graph"; in select_tracer()
613 ftrace->tracer = "function"; in select_tracer()
616 pr_debug("%s tracer is used\n", ftrace->tracer); in select_tracer()
619 static int __cmd_ftrace(struct perf_ftrace *ftrace) in __cmd_ftrace() argument
628 select_tracer(ftrace); in __cmd_ftrace()
630 if (reset_tracing_files(ftrace) < 0) { in __cmd_ftrace()
631 pr_err("failed to reset ftrace\n"); in __cmd_ftrace()
635 /* reset ftrace buffer */ in __cmd_ftrace()
639 if (set_tracing_options(ftrace) < 0) in __cmd_ftrace()
642 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { in __cmd_ftrace()
643 pr_err("failed to set current_tracer to %s\n", ftrace->tracer); in __cmd_ftrace()
670 if (!ftrace->target.initial_delay) { in __cmd_ftrace()
677 evlist__start_workload(ftrace->evlist); in __cmd_ftrace()
679 if (ftrace->target.initial_delay > 0) { in __cmd_ftrace()
680 usleep(ftrace->target.initial_delay * 1000); in __cmd_ftrace()
688 if (poll(&pollfd, 1, -1) < 0) in __cmd_ftrace()
724 reset_tracing_files(ftrace); in __cmd_ftrace()
726 return (done && !workload_exec_errno) ? 0 : -1; in __cmd_ftrace()
784 i = NUM_BUCKET - 1; in make_histogram()
813 printf("# %14s | %10s | %-*s |\n", in display_histogram()
817 printf(" %4d - %-4d %s | %10d | %.*s%*s |\n", in display_histogram()
818 0, 1, use_nsec ? "ns" : "us", buckets[0], bar_len, bar, bar_total - bar_len, ""); in display_histogram()
820 for (i = 1; i < NUM_BUCKET - 1; i++) { in display_histogram()
821 int start = (1 << (i - 1)); in display_histogram()
831 printf(" %4d - %-4d %s | %10d | %.*s%*s |\n", in display_histogram()
833 bar_total - bar_len, ""); in display_histogram()
836 bar_len = buckets[NUM_BUCKET - 1] * bar_total / total; in display_histogram()
837 printf(" %4d - %-4s %s | %10d | %.*s%*s |\n", in display_histogram()
838 1, "...", use_nsec ? "ms" : " s", buckets[NUM_BUCKET - 1], in display_histogram()
839 bar_len, bar, bar_total - bar_len, ""); in display_histogram()
843 static int prepare_func_latency(struct perf_ftrace *ftrace) in prepare_func_latency() argument
848 if (ftrace->target.use_bpf) in prepare_func_latency()
849 return perf_ftrace__latency_prepare_bpf(ftrace); in prepare_func_latency()
851 if (reset_tracing_files(ftrace) < 0) { in prepare_func_latency()
852 pr_err("failed to reset ftrace\n"); in prepare_func_latency()
853 return -1; in prepare_func_latency()
856 /* reset ftrace buffer */ in prepare_func_latency()
858 return -1; in prepare_func_latency()
860 if (set_tracing_options(ftrace) < 0) in prepare_func_latency()
861 return -1; in prepare_func_latency()
866 return -1; in prepare_func_latency()
872 return -1; in prepare_func_latency()
883 static int start_func_latency(struct perf_ftrace *ftrace) in start_func_latency() argument
885 if (ftrace->target.use_bpf) in start_func_latency()
886 return perf_ftrace__latency_start_bpf(ftrace); in start_func_latency()
890 return -1; in start_func_latency()
896 static int stop_func_latency(struct perf_ftrace *ftrace) in stop_func_latency() argument
898 if (ftrace->target.use_bpf) in stop_func_latency()
899 return perf_ftrace__latency_stop_bpf(ftrace); in stop_func_latency()
905 static int read_func_latency(struct perf_ftrace *ftrace, int buckets[]) in read_func_latency() argument
907 if (ftrace->target.use_bpf) in read_func_latency()
908 return perf_ftrace__latency_read_bpf(ftrace, buckets); in read_func_latency()
913 static int cleanup_func_latency(struct perf_ftrace *ftrace) in cleanup_func_latency() argument
915 if (ftrace->target.use_bpf) in cleanup_func_latency()
916 return perf_ftrace__latency_cleanup_bpf(ftrace); in cleanup_func_latency()
918 reset_tracing_files(ftrace); in cleanup_func_latency()
922 static int __cmd_latency(struct perf_ftrace *ftrace) in __cmd_latency() argument
932 trace_fd = prepare_func_latency(ftrace); in __cmd_latency()
939 if (start_func_latency(ftrace) < 0) in __cmd_latency()
942 evlist__start_workload(ftrace->evlist); in __cmd_latency()
946 if (poll(&pollfd, 1, -1) < 0) in __cmd_latency()
950 int n = read(trace_fd, buf, sizeof(buf) - 1); in __cmd_latency()
954 make_histogram(buckets, buf, n, line, ftrace->use_nsec); in __cmd_latency()
958 stop_func_latency(ftrace); in __cmd_latency()
967 while (!ftrace->target.use_bpf) { in __cmd_latency()
968 int n = read(trace_fd, buf, sizeof(buf) - 1); in __cmd_latency()
971 make_histogram(buckets, buf, n, line, ftrace->use_nsec); in __cmd_latency()
974 read_func_latency(ftrace, buckets); in __cmd_latency()
976 display_histogram(buckets, ftrace->use_nsec); in __cmd_latency()
980 cleanup_func_latency(ftrace); in __cmd_latency()
982 return (done && !workload_exec_errno) ? 0 : -1; in __cmd_latency()
995 static int prepare_func_profile(struct perf_ftrace *ftrace) in prepare_func_profile() argument
997 ftrace->tracer = "function_graph"; in prepare_func_profile()
998 ftrace->graph_tail = 1; in prepare_func_profile()
1000 ftrace->profile_hash = hashmap__new(profile_hash, profile_equal, NULL); in prepare_func_profile()
1001 if (ftrace->profile_hash == NULL) in prepare_func_profile()
1002 return -ENOMEM; in prepare_func_profile()
1012 static int add_func_duration(struct perf_ftrace *ftrace, char *func, double time_ns) in add_func_duration() argument
1016 if (!hashmap__find(ftrace->profile_hash, func, &prof)) { in add_func_duration()
1020 return -ENOMEM; in add_func_duration()
1025 return -ENOMEM; in add_func_duration()
1028 init_stats(&prof->st); in add_func_duration()
1029 hashmap__add(ftrace->profile_hash, key, prof); in add_func_duration()
1032 update_stats(&prof->st, time_ns); in add_func_duration()
1037 * The ftrace function_graph text output normally looks like below:
1053 static int parse_func_duration(struct perf_ftrace *ftrace, char *line, size_t len) in parse_func_duration() argument
1078 pr_debug("non-usec time found.. ignoring\n"); in parse_func_duration()
1093 return -EINVAL; in parse_func_duration()
1102 /* remove semi-colon or end of comment at the end */ in parse_func_duration()
1103 p = line + len - 1; in parse_func_duration()
1106 --p; in parse_func_duration()
1109 return add_func_duration(ftrace, func, duration); in parse_func_duration()
1126 struct ftrace_profile_data *p1 = e1->pvalue; in cmp_profile_data()
1127 struct ftrace_profile_data *p2 = e2->pvalue; in cmp_profile_data()
1132 return strcmp(e1->pkey, e2->pkey); in cmp_profile_data()
1134 v1 = p1->st.mean; in cmp_profile_data()
1135 v2 = p2->st.mean; in cmp_profile_data()
1138 v1 = p1->st.max; in cmp_profile_data()
1139 v2 = p2->st.max; in cmp_profile_data()
1142 v1 = p1->st.n; in cmp_profile_data()
1143 v2 = p2->st.n; in cmp_profile_data()
1147 v1 = p1->st.n * p1->st.mean; in cmp_profile_data()
1148 v2 = p2->st.n * p2->st.mean; in cmp_profile_data()
1153 return -1; in cmp_profile_data()
1159 static void print_profile_result(struct perf_ftrace *ftrace) in print_profile_result() argument
1164 nr = hashmap__size(ftrace->profile_hash); in print_profile_result()
1175 hashmap__for_each_entry(ftrace->profile_hash, entry, bkt) in print_profile_result()
1187 const char *name = profile[i]->pkey; in print_profile_result()
1188 struct ftrace_profile_data *p = profile[i]->pvalue; in print_profile_result()
1191 p->st.n * p->st.mean / 1000, p->st.mean / 1000, in print_profile_result()
1192 p->st.max / 1000, p->st.max % 1000, p->st.n, name); in print_profile_result()
1197 hashmap__for_each_entry(ftrace->profile_hash, entry, bkt) { in print_profile_result()
1198 free((char *)entry->pkey); in print_profile_result()
1199 free(entry->pvalue); in print_profile_result()
1202 hashmap__free(ftrace->profile_hash); in print_profile_result()
1203 ftrace->profile_hash = NULL; in print_profile_result()
1206 static int __cmd_profile(struct perf_ftrace *ftrace) in __cmd_profile() argument
1215 if (prepare_func_profile(ftrace) < 0) { in __cmd_profile()
1220 if (reset_tracing_files(ftrace) < 0) { in __cmd_profile()
1221 pr_err("failed to reset ftrace\n"); in __cmd_profile()
1225 /* reset ftrace buffer */ in __cmd_profile()
1229 if (set_tracing_options(ftrace) < 0) in __cmd_profile()
1230 return -1; in __cmd_profile()
1232 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { in __cmd_profile()
1233 pr_err("failed to set current_tracer to %s\n", ftrace->tracer); in __cmd_profile()
1261 evlist__start_workload(ftrace->evlist); in __cmd_profile()
1264 io.timeout_ms = -1; in __cmd_profile()
1270 if (parse_func_duration(ftrace, line, line_len) < 0) in __cmd_profile()
1290 if (parse_func_duration(ftrace, line, line_len) < 0) in __cmd_profile()
1294 print_profile_result(ftrace); in __cmd_profile()
1301 reset_tracing_files(ftrace); in __cmd_profile()
1303 return (done && !workload_exec_errno) ? 0 : -1; in __cmd_profile()
1308 struct perf_ftrace *ftrace = cb; in perf_ftrace_config() local
1310 if (!strstarts(var, "ftrace.")) in perf_ftrace_config()
1313 if (strcmp(var, "ftrace.tracer")) in perf_ftrace_config()
1314 return -1; in perf_ftrace_config()
1318 ftrace->tracer = value; in perf_ftrace_config()
1323 return -1; in perf_ftrace_config()
1342 return -1; in opt_list_avail_functions()
1346 return err ? -EINVAL : -ENOMEM; in opt_list_avail_functions()
1349 if (ret == -EINVAL) { in opt_list_avail_functions()
1350 pr_err("Filter parse error at %td.\n", err - str + 1); in opt_list_avail_functions()
1352 pr_err(" %*c\n", (int)(err - str + 1), '^'); in opt_list_avail_functions()
1369 struct list_head *head = opt->value; in parse_filter_func()
1374 return -ENOMEM; in parse_filter_func()
1376 strcpy(entry->name, str); in parse_filter_func()
1377 list_add_tail(&entry->list, head); in parse_filter_func()
1387 list_del_init(&pos->list); in delete_filter_func()
1395 unsigned long *s = (unsigned long *)opt->value; in parse_buffer_size()
1411 if (val != (unsigned long) -1) { in parse_buffer_size()
1413 pr_err("buffer size too small, must larger than 1KB."); in parse_buffer_size()
1414 return -1; in parse_buffer_size()
1420 return -1; in parse_buffer_size()
1427 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value; in parse_func_tracer_opts() local
1429 { .name = "call-graph", .value_ptr = &ftrace->func_stack_trace }, in parse_func_tracer_opts()
1430 { .name = "irq-info", .value_ptr = &ftrace->func_irq_info }, in parse_func_tracer_opts()
1448 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value; in parse_graph_tracer_opts() local
1450 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time }, in parse_graph_tracer_opts()
1451 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs }, in parse_graph_tracer_opts()
1452 { .name = "verbose", .value_ptr = &ftrace->graph_verbose }, in parse_graph_tracer_opts()
1453 { .name = "thresh", .value_ptr = &ftrace->graph_thresh }, in parse_graph_tracer_opts()
1454 { .name = "depth", .value_ptr = &ftrace->graph_depth }, in parse_graph_tracer_opts()
1455 { .name = "tail", .value_ptr = &ftrace->graph_tail }, in parse_graph_tracer_opts()
1471 enum perf_ftrace_profile_sort_key *key = (void *)opt->value; in parse_sort_key()
1488 return -1; in parse_sort_key()
1504 struct perf_ftrace ftrace = { in cmd_ftrace() local
1509 OPT_STRING('p', "pid", &ftrace.target.pid, "pid", in cmd_ftrace()
1511 /* TODO: Add short option -t after -t/--tracer can be removed. */ in cmd_ftrace()
1512 OPT_STRING(0, "tid", &ftrace.target.tid, "tid", in cmd_ftrace()
1513 "Trace on existing thread id (exclusive to --pid)"), in cmd_ftrace()
1516 OPT_BOOLEAN('a', "all-cpus", &ftrace.target.system_wide, in cmd_ftrace()
1517 "System-wide collection from all CPUs"), in cmd_ftrace()
1518 OPT_STRING('C', "cpu", &ftrace.target.cpu_list, "cpu", in cmd_ftrace()
1523 OPT_STRING('t', "tracer", &ftrace.tracer, "tracer", in cmd_ftrace()
1528 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func", in cmd_ftrace()
1531 OPT_CALLBACK('N', "notrace-funcs", &ftrace.notrace, "func", in cmd_ftrace()
1533 OPT_CALLBACK(0, "func-opts", &ftrace, "options", in cmd_ftrace()
1534 "Function tracer options, available options: call-graph,irq-info", in cmd_ftrace()
1536 OPT_CALLBACK('G', "graph-funcs", &ftrace.graph_funcs, "func", in cmd_ftrace()
1539 OPT_CALLBACK('g', "nograph-funcs", &ftrace.nograph_funcs, "func", in cmd_ftrace()
1541 OPT_CALLBACK(0, "graph-opts", &ftrace, "options", in cmd_ftrace()
1542 "Graph tracer options, available options: nosleep-time,noirqs,verbose,thresh=<n>,depth=<n>", in cmd_ftrace()
1544 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", in cmd_ftrace()
1545 "Size of per cpu buffer, needs to use a B, K, M or G suffix.", parse_buffer_size), in cmd_ftrace()
1546 OPT_BOOLEAN(0, "inherit", &ftrace.inherit, in cmd_ftrace()
1548 OPT_INTEGER('D', "delay", &ftrace.target.initial_delay, in cmd_ftrace()
1553 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func", in cmd_ftrace()
1556 OPT_BOOLEAN('b', "use-bpf", &ftrace.target.use_bpf, in cmd_ftrace()
1559 OPT_BOOLEAN('n', "use-nsec", &ftrace.use_nsec, in cmd_ftrace()
1560 "Use nano-second histogram"), in cmd_ftrace()
1564 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func", in cmd_ftrace()
1567 OPT_CALLBACK('N', "notrace-funcs", &ftrace.notrace, "func", in cmd_ftrace()
1569 OPT_CALLBACK('G', "graph-funcs", &ftrace.graph_funcs, "func", in cmd_ftrace()
1572 OPT_CALLBACK('g', "nograph-funcs", &ftrace.nograph_funcs, "func", in cmd_ftrace()
1574 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size", in cmd_ftrace()
1575 "Size of per cpu buffer, needs to use a B, K, M or G suffix.", parse_buffer_size), in cmd_ftrace()
1584 "perf ftrace [<options>] [<command>]", in cmd_ftrace()
1585 "perf ftrace [<options>] -- [<command>] [<options>]", in cmd_ftrace()
1586 "perf ftrace {trace|latency|profile} [<options>] [<command>]", in cmd_ftrace()
1587 "perf ftrace {trace|latency|profile} [<options>] -- [<command>] [<options>]", in cmd_ftrace()
1592 INIT_LIST_HEAD(&ftrace.filters); in cmd_ftrace()
1593 INIT_LIST_HEAD(&ftrace.notrace); in cmd_ftrace()
1594 INIT_LIST_HEAD(&ftrace.graph_funcs); in cmd_ftrace()
1595 INIT_LIST_HEAD(&ftrace.nograph_funcs); in cmd_ftrace()
1603 return -1; in cmd_ftrace()
1606 pr_err("ftrace is not supported on this system\n"); in cmd_ftrace()
1607 return -ENOTSUP; in cmd_ftrace()
1610 ret = perf_config(perf_ftrace_config, &ftrace); in cmd_ftrace()
1612 return -1; in cmd_ftrace()
1626 argc--; in cmd_ftrace()
1637 ret = -EINVAL; in cmd_ftrace()
1641 /* Make system wide (-a) the default target. */ in cmd_ftrace()
1642 if (!argc && target__none(&ftrace.target)) in cmd_ftrace()
1643 ftrace.target.system_wide = true; in cmd_ftrace()
1650 if (list_empty(&ftrace.filters)) { in cmd_ftrace()
1653 ret = -EINVAL; in cmd_ftrace()
1664 ret = -EINVAL; in cmd_ftrace()
1668 ret = target__validate(&ftrace.target); in cmd_ftrace()
1672 target__strerror(&ftrace.target, ret, errbuf, 512); in cmd_ftrace()
1677 ftrace.evlist = evlist__new(); in cmd_ftrace()
1678 if (ftrace.evlist == NULL) { in cmd_ftrace()
1679 ret = -ENOMEM; in cmd_ftrace()
1683 ret = evlist__create_maps(ftrace.evlist, &ftrace.target); in cmd_ftrace()
1688 ret = evlist__prepare_workload(ftrace.evlist, &ftrace.target, in cmd_ftrace()
1695 ret = cmd_func(&ftrace); in cmd_ftrace()
1698 evlist__delete(ftrace.evlist); in cmd_ftrace()
1701 delete_filter_func(&ftrace.filters); in cmd_ftrace()
1702 delete_filter_func(&ftrace.notrace); in cmd_ftrace()
1703 delete_filter_func(&ftrace.graph_funcs); in cmd_ftrace()
1704 delete_filter_func(&ftrace.nograph_funcs); in cmd_ftrace()