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 mem: Add -s/--sort option

So that users can set the sort key manually as they want.

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

-s, --sort <key[,key2...]>
sort by key(s): overhead overhead_sys overhead_us overhead_guest_sys
overhead_guest_us overhead_children sample period
weight1 weight2 weight3 ins_lat retire_lat p_stage_cyc
pid comm dso symbol parent cpu socket srcline srcfile
local_weight weight transaction trace symbol_size
dso_size cgroup cgroup_id ipc_null time code_page_size
local_ins_lat ins_lat local_p_stage_cyc p_stage_cyc
addr local_retire_lat retire_lat simd type typeoff
symoff symbol_daddr dso_daddr locked tlb mem snoop
dcacheline symbol_iaddr phys_daddr data_page_size
blocked

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-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
2d99a991 871893d7

+9 -2
+9 -2
tools/perf/builtin-mem.c
··· 19 19 #include "util/symbol.h" 20 20 #include "util/pmus.h" 21 21 #include "util/sample.h" 22 + #include "util/sort.h" 22 23 #include "util/string2.h" 23 24 #include "util/util.h" 24 25 #include <linux/err.h> ··· 29 28 30 29 struct perf_mem { 31 30 struct perf_tool tool; 32 - char const *input_name; 31 + const char *input_name; 32 + const char *sort_key; 33 33 bool hide_unresolved; 34 34 bool dump_raw; 35 35 bool force; ··· 315 313 bool has_extra_options = (mem->phys_addr | mem->data_page_size) ? true : false; 316 314 char sort[128]; 317 315 316 + if (mem->sort_key) 317 + scnprintf(sort, sizeof(sort), "--sort=%s", mem->sort_key); 318 318 /* 319 319 * there is no weight (cost) associated with stores, so don't print 320 320 * the column 321 321 */ 322 - if (!(mem->operation & MEM_OPERATION_LOAD)) { 322 + else if (!(mem->operation & MEM_OPERATION_LOAD)) { 323 323 strcpy(sort, "--sort=mem,sym,dso,symbol_daddr," 324 324 "dso_daddr,tlb,locked"); 325 325 } else if (has_extra_options) { ··· 472 468 */ 473 469 .operation = MEM_OPERATION_LOAD | MEM_OPERATION_STORE, 474 470 }; 471 + char *sort_order_help = sort_help("sort by key(s):", SORT_MODE__MEMORY); 475 472 const struct option mem_options[] = { 476 473 OPT_CALLBACK('t', "type", &mem.operation, 477 474 "type", "memory operations(load,store) Default load,store", ··· 506 501 "separator", 507 502 "separator for columns, no spaces will be added" 508 503 " between columns '.' is reserved."), 504 + OPT_STRING('s', "sort", &mem.sort_key, "key[,key2...]", 505 + sort_order_help), 509 506 OPT_PARENT(mem_options) 510 507 }; 511 508 const char *const mem_subcommands[] = { "record", "report", NULL };