Lines Matching refs:ftrace
3 * builtin-ftrace.c
245 static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)
257 static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
278 reset_tracing_options(ftrace);
282 static int set_tracing_pid(struct perf_ftrace *ftrace)
287 if (target__has_cpu(&ftrace->target))
290 for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
292 perf_thread_map__pid(ftrace->evlist->core.threads, i));
324 static int set_tracing_cpu(struct perf_ftrace *ftrace)
326 struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus;
328 if (!target__has_cpu(&ftrace->target))
334 static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace)
336 if (!ftrace->func_stack_trace)
345 static int set_tracing_func_irqinfo(struct perf_ftrace *ftrace)
347 if (!ftrace->func_irq_info)
378 static int set_tracing_filters(struct perf_ftrace *ftrace)
382 ret = __set_tracing_filter("set_ftrace_filter", &ftrace->filters);
386 ret = __set_tracing_filter("set_ftrace_notrace", &ftrace->notrace);
390 ret = __set_tracing_filter("set_graph_function", &ftrace->graph_funcs);
395 __set_tracing_filter("set_graph_notrace", &ftrace->nograph_funcs);
408 static int set_tracing_depth(struct perf_ftrace *ftrace)
410 if (ftrace->graph_depth == 0)
413 if (ftrace->graph_depth < 0) {
414 pr_err("invalid graph depth: %d\n", ftrace->graph_depth);
418 if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0)
424 static int set_tracing_percpu_buffer_size(struct perf_ftrace *ftrace)
428 if (ftrace->percpu_buffer_size == 0)
432 ftrace->percpu_buffer_size / 1024);
439 static int set_tracing_trace_inherit(struct perf_ftrace *ftrace)
441 if (!ftrace->inherit)
450 static int set_tracing_sleep_time(struct perf_ftrace *ftrace)
452 if (!ftrace->graph_nosleep_time)
461 static int set_tracing_funcgraph_irqs(struct perf_ftrace *ftrace)
463 if (!ftrace->graph_noirqs)
472 static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
474 if (!ftrace->graph_verbose)
489 static int set_tracing_thresh(struct perf_ftrace *ftrace)
493 if (ftrace->graph_thresh == 0)
496 ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
503 static int set_tracing_options(struct perf_ftrace *ftrace)
505 if (set_tracing_pid(ftrace) < 0) {
506 pr_err("failed to set ftrace pid\n");
510 if (set_tracing_cpu(ftrace) < 0) {
515 if (set_tracing_func_stack_trace(ftrace) < 0) {
520 if (set_tracing_func_irqinfo(ftrace) < 0) {
525 if (set_tracing_filters(ftrace) < 0) {
530 if (set_tracing_depth(ftrace) < 0) {
535 if (set_tracing_percpu_buffer_size(ftrace) < 0) {
540 if (set_tracing_trace_inherit(ftrace) < 0) {
545 if (set_tracing_sleep_time(ftrace) < 0) {
550 if (set_tracing_funcgraph_irqs(ftrace) < 0) {
555 if (set_tracing_funcgraph_verbose(ftrace) < 0) {
560 if (set_tracing_thresh(ftrace) < 0) {
568 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
579 pr_err("ftrace only works for %s!\n",
594 if (reset_tracing_files(ftrace) < 0) {
595 pr_err("failed to reset ftrace\n");
599 /* reset ftrace buffer */
603 if (argc && perf_evlist__prepare_workload(ftrace->evlist,
604 &ftrace->target, argv, false,
609 if (set_tracing_options(ftrace) < 0)
612 if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
613 pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
640 if (!ftrace->initial_delay) {
647 perf_evlist__start_workload(ftrace->evlist);
649 if (ftrace->initial_delay) {
650 usleep(ftrace->initial_delay * 1000);
692 reset_tracing_files(ftrace);
699 struct perf_ftrace *ftrace = cb;
701 if (!strstarts(var, "ftrace."))
704 if (strcmp(var, "ftrace.tracer"))
709 ftrace->tracer = value;
818 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
820 { .name = "call-graph", .value_ptr = &ftrace->func_stack_trace },
821 { .name = "irq-info", .value_ptr = &ftrace->func_irq_info },
839 struct perf_ftrace *ftrace = (struct perf_ftrace *) opt->value;
841 { .name = "nosleep-time", .value_ptr = &ftrace->graph_nosleep_time },
842 { .name = "noirqs", .value_ptr = &ftrace->graph_noirqs },
843 { .name = "verbose", .value_ptr = &ftrace->graph_verbose },
844 { .name = "thresh", .value_ptr = &ftrace->graph_thresh },
845 { .name = "depth", .value_ptr = &ftrace->graph_depth },
859 static void select_tracer(struct perf_ftrace *ftrace)
861 bool graph = !list_empty(&ftrace->graph_funcs) ||
862 !list_empty(&ftrace->nograph_funcs);
863 bool func = !list_empty(&ftrace->filters) ||
864 !list_empty(&ftrace->notrace);
868 ftrace->tracer = "function_graph";
870 ftrace->tracer = "function";
873 pr_debug("%s tracer is used\n", ftrace->tracer);
879 struct perf_ftrace ftrace = {
884 "perf ftrace [<options>] [<command>]",
885 "perf ftrace [<options>] -- <command> [<options>]",
889 OPT_STRING('t', "tracer", &ftrace.tracer, "tracer",
894 OPT_STRING('p', "pid", &ftrace.target.pid, "pid",
897 OPT_STRING(0, "tid", &ftrace.target.tid, "tid",
901 OPT_BOOLEAN('a', "all-cpus", &ftrace.target.system_wide,
903 OPT_STRING('C', "cpu", &ftrace.target.cpu_list, "cpu",
905 OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func",
908 OPT_CALLBACK('N', "notrace-funcs", &ftrace.notrace, "func",
910 OPT_CALLBACK(0, "func-opts", &ftrace, "options",
913 OPT_CALLBACK('G', "graph-funcs", &ftrace.graph_funcs, "func",
916 OPT_CALLBACK('g', "nograph-funcs", &ftrace.nograph_funcs, "func",
918 OPT_CALLBACK(0, "graph-opts", &ftrace, "options",
921 OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
923 OPT_BOOLEAN(0, "inherit", &ftrace.inherit,
925 OPT_UINTEGER('D', "delay", &ftrace.initial_delay,
930 INIT_LIST_HEAD(&ftrace.filters);
931 INIT_LIST_HEAD(&ftrace.notrace);
932 INIT_LIST_HEAD(&ftrace.graph_funcs);
933 INIT_LIST_HEAD(&ftrace.nograph_funcs);
935 ret = perf_config(perf_ftrace_config, &ftrace);
941 if (!argc && target__none(&ftrace.target))
942 ftrace.target.system_wide = true;
944 select_tracer(&ftrace);
946 ret = target__validate(&ftrace.target);
950 target__strerror(&ftrace.target, ret, errbuf, 512);
955 ftrace.evlist = evlist__new();
956 if (ftrace.evlist == NULL) {
961 ret = perf_evlist__create_maps(ftrace.evlist, &ftrace.target);
965 ret = __cmd_ftrace(&ftrace, argc, argv);
968 evlist__delete(ftrace.evlist);
971 delete_filter_func(&ftrace.filters);
972 delete_filter_func(&ftrace.notrace);
973 delete_filter_func(&ftrace.graph_funcs);
974 delete_filter_func(&ftrace.nograph_funcs);