[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211215185154.360314-2-namhyung@kernel.org>
Date: Wed, 15 Dec 2021 10:51:50 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
LKML <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Ian Rogers <irogers@...gle.com>,
Changbin Du <changbin.du@...il.com>,
Song Liu <songliubraving@...com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
Stephane Eranian <eranian@...gle.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH 1/5] perf ftrace: Add 'trace' subcommand
This is a preparation to add more sub-commands for ftrace. The
'trace' subcommand does the same thing when no subcommand is given.
Committer testing:
The previous mode, i.e. no subcommand and the new 'perf ftrace trace'
are equivalent:
# perf ftrace -G check_preempt_curr sleep 0.00001
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
25) | check_preempt_curr() {
25) | resched_curr() {
25) | native_smp_send_reschedule() {
25) | default_send_IPI_single_phys() {
25) 0.110 us | __default_send_IPI_dest_field();
25) 0.490 us | }
25) 0.640 us | }
25) 0.850 us | }
25) 2.060 us | }
# perf ftrace trace -G check_preempt_curr sleep 0.00001
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
10) | check_preempt_curr() {
10) | resched_curr() {
10) | native_smp_send_reschedule() {
10) | default_send_IPI_single_phys() {
10) 0.080 us | __default_send_IPI_dest_field();
10) 0.460 us | }
10) 0.610 us | }
10) 0.830 us | }
10) 2.020 us | }
#
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Changbin Du <changbin.du@...il.com>
Cc: Ian Rogers <irogers@...gle.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Song Liu <songliubraving@...com>
Cc: Stephane Eranian <eranian@...gle.com>
Link: https://lore.kernel.org/r/20211129231830.1117781-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-ftrace.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 87cb11a7a3ee..b28e762c5d54 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -879,17 +879,7 @@ int cmd_ftrace(int argc, const char **argv)
.tracer = DEFAULT_TRACER,
.target = { .uid = UINT_MAX, },
};
- const char * const ftrace_usage[] = {
- "perf ftrace [<options>] [<command>]",
- "perf ftrace [<options>] -- <command> [<options>]",
- NULL
- };
- const struct option ftrace_options[] = {
- OPT_STRING('t', "tracer", &ftrace.tracer, "tracer",
- "Tracer to use: function_graph(default) or function"),
- OPT_CALLBACK_DEFAULT('F', "funcs", NULL, "[FILTER]",
- "Show available functions to filter",
- opt_list_avail_functions, "*"),
+ const struct option common_options[] = {
OPT_STRING('p', "pid", &ftrace.target.pid, "pid",
"Trace on existing process id"),
/* TODO: Add short option -t after -t/--tracer can be removed. */
@@ -901,6 +891,14 @@ int cmd_ftrace(int argc, const char **argv)
"System-wide collection from all CPUs"),
OPT_STRING('C', "cpu", &ftrace.target.cpu_list, "cpu",
"List of cpus to monitor"),
+ OPT_END()
+ };
+ const struct option ftrace_options[] = {
+ OPT_STRING('t', "tracer", &ftrace.tracer, "tracer",
+ "Tracer to use: function_graph(default) or function"),
+ OPT_CALLBACK_DEFAULT('F', "funcs", NULL, "[FILTER]",
+ "Show available functions to filter",
+ opt_list_avail_functions, "*"),
OPT_CALLBACK('T', "trace-funcs", &ftrace.filters, "func",
"Trace given functions using function tracer",
parse_filter_func),
@@ -923,7 +921,15 @@ int cmd_ftrace(int argc, const char **argv)
"Trace children processes"),
OPT_UINTEGER('D', "delay", &ftrace.initial_delay,
"Number of milliseconds to wait before starting tracing after program start"),
- OPT_END()
+ OPT_PARENT(common_options),
+ };
+
+ const char * const ftrace_usage[] = {
+ "perf ftrace [<options>] [<command>]",
+ "perf ftrace [<options>] -- [<command>] [<options>]",
+ "perf ftrace trace [<options>] [<command>]",
+ "perf ftrace trace [<options>] -- [<command>] [<options>]",
+ NULL
};
INIT_LIST_HEAD(&ftrace.filters);
@@ -935,6 +941,11 @@ int cmd_ftrace(int argc, const char **argv)
if (ret < 0)
return -1;
+ if (argc > 1 && !strcmp(argv[1], "trace")) {
+ argc--;
+ argv++;
+ }
+
argc = parse_options(argc, argv, ftrace_options, ftrace_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && target__none(&ftrace.target))
--
2.34.1.173.g76aa8bc2d0-goog
Powered by blists - more mailing lists