Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf tools: Add mode argument to sort_help()

Some sort keys are meaningful only in a specific mode - like branch
stack and memory (data-src). Add the mode to skip unnecessary ones.
This will be used for 'perf mem report' later.

While at it, change the prefix for the -F/--fields option to remove
the duplicate part.

Before:

$ perf report -F
Error: switch `F' requires a value
Usage: perf report [<options>]

-F, --fields <key[,keys...]>
output field(s): overhead period sample overhead overhead_sys
overhead_us overhead_guest_sys overhead_guest_us overhead_children
sample period weight1 weight2 weight3 ins_lat retire_lat
...
After:

$ perf report -F
Error: switch `F' requires a value
Usage: perf report [<options>]

-F, --fields <key[,keys...]>
output field(s): overhead overhead_sys overhead_us
overhead_guest_sys overhead_guest_us overhead_children
sample period weight1 weight2 weight3 ins_lat retire_lat
...

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240731235505.710436-5-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
871893d7 35b38a71

+10 -8
+2 -2
tools/perf/builtin-report.c
··· 1301 1301 .socket_filter = -1, 1302 1302 .skip_empty = true, 1303 1303 }; 1304 - char *sort_order_help = sort_help("sort by key(s):"); 1305 - char *field_order_help = sort_help("output field(s): overhead period sample "); 1304 + char *sort_order_help = sort_help("sort by key(s):", SORT_MODE__NORMAL); 1305 + char *field_order_help = sort_help("output field(s):", SORT_MODE__NORMAL); 1306 1306 const char *disassembler_style = NULL, *objdump_path = NULL, *addr2line_path = NULL; 1307 1307 const struct option options[] = { 1308 1308 OPT_STRING('i', "input", &input_name, "file",
+7 -5
tools/perf/util/sort.c
··· 3960 3960 add_key(sb, s[i].name, llen); 3961 3961 } 3962 3962 3963 - char *sort_help(const char *prefix) 3963 + char *sort_help(const char *prefix, enum sort_mode mode) 3964 3964 { 3965 3965 struct strbuf sb; 3966 3966 char *s; ··· 3972 3972 ARRAY_SIZE(hpp_sort_dimensions), &len); 3973 3973 add_sort_string(&sb, common_sort_dimensions, 3974 3974 ARRAY_SIZE(common_sort_dimensions), &len); 3975 - add_sort_string(&sb, bstack_sort_dimensions, 3976 - ARRAY_SIZE(bstack_sort_dimensions), &len); 3977 - add_sort_string(&sb, memory_sort_dimensions, 3978 - ARRAY_SIZE(memory_sort_dimensions), &len); 3975 + if (mode == SORT_MODE__NORMAL || mode == SORT_MODE__BRANCH) 3976 + add_sort_string(&sb, bstack_sort_dimensions, 3977 + ARRAY_SIZE(bstack_sort_dimensions), &len); 3978 + if (mode == SORT_MODE__NORMAL || mode == SORT_MODE__MEMORY) 3979 + add_sort_string(&sb, memory_sort_dimensions, 3980 + ARRAY_SIZE(memory_sort_dimensions), &len); 3979 3981 s = strbuf_detach(&sb, NULL); 3980 3982 strbuf_release(&sb); 3981 3983 return s;
+1 -1
tools/perf/util/sort.h
··· 130 130 void sort__setup_elide(FILE *fp); 131 131 void perf_hpp__set_elide(int idx, bool elide); 132 132 133 - char *sort_help(const char *prefix); 133 + char *sort_help(const char *prefix, enum sort_mode mode); 134 134 135 135 int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset); 136 136