forked from Minki/linux
perf report: Show all sort keys in help output
Show all the supported sort keys in the command line help output, so that it's not needed to refer to the manpage. Before: % perf report -h ... -s, --sort <key[,key2...]> sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ... Please refer the man page for the complete list. After: % perf report -h ... -s, --sort <key[,key2...]> sort by key(s): overhead overhead_sys overhead_us overhead_guest_sys overhead_guest_us overhead_children sample period pid comm dso symbol parent cpu ... Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> LPU-Reference: 20190314225002.30108-5-andi@firstfloor.org Link: https://lkml.kernel.org/n/tip-9r3uz2ch4izoi1uln3f889co@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c38dab7df7
commit
702fb9b415
@ -1083,10 +1083,9 @@ int cmd_report(int argc, const char **argv)
|
|||||||
OPT_BOOLEAN(0, "header-only", &report.header_only,
|
OPT_BOOLEAN(0, "header-only", &report.header_only,
|
||||||
"Show only data header."),
|
"Show only data header."),
|
||||||
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
|
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
|
||||||
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
|
sort_help("sort by key(s):")),
|
||||||
" Please refer the man page for the complete list."),
|
|
||||||
OPT_STRING('F', "fields", &field_order, "key[,keys...]",
|
OPT_STRING('F', "fields", &field_order, "key[,keys...]",
|
||||||
"output field(s): overhead, period, sample plus all of sort keys"),
|
sort_help("output field(s): overhead period sample ")),
|
||||||
OPT_BOOLEAN(0, "show-cpu-utilization", &symbol_conf.show_cpu_utilization,
|
OPT_BOOLEAN(0, "show-cpu-utilization", &symbol_conf.show_cpu_utilization,
|
||||||
"Show sample percentage for different cpu modes"),
|
"Show sample percentage for different cpu modes"),
|
||||||
OPT_BOOLEAN_FLAG(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
|
OPT_BOOLEAN_FLAG(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "evsel.h"
|
#include "evsel.h"
|
||||||
#include "evlist.h"
|
#include "evlist.h"
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
#include "strbuf.h"
|
||||||
#include <traceevent/event-parse.h>
|
#include <traceevent/event-parse.h>
|
||||||
#include "mem-events.h"
|
#include "mem-events.h"
|
||||||
#include "annotate.h"
|
#include "annotate.h"
|
||||||
@ -3107,3 +3108,54 @@ void reset_output_field(void)
|
|||||||
reset_dimensions();
|
reset_dimensions();
|
||||||
perf_hpp__reset_output_field(&perf_hpp_list);
|
perf_hpp__reset_output_field(&perf_hpp_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define INDENT (3*8 + 1)
|
||||||
|
|
||||||
|
static void add_key(struct strbuf *sb, const char *str, int *llen)
|
||||||
|
{
|
||||||
|
if (*llen >= 75) {
|
||||||
|
strbuf_addstr(sb, "\n\t\t\t ");
|
||||||
|
*llen = INDENT;
|
||||||
|
}
|
||||||
|
strbuf_addf(sb, " %s", str);
|
||||||
|
*llen += strlen(str) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void add_sort_string(struct strbuf *sb, struct sort_dimension *s, int n,
|
||||||
|
int *llen)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
add_key(sb, s[i].name, llen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void add_hpp_sort_string(struct strbuf *sb, struct hpp_dimension *s, int n,
|
||||||
|
int *llen)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
add_key(sb, s[i].name, llen);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *sort_help(const char *prefix)
|
||||||
|
{
|
||||||
|
struct strbuf sb;
|
||||||
|
char *s;
|
||||||
|
int len = strlen(prefix) + INDENT;
|
||||||
|
|
||||||
|
strbuf_init(&sb, 300);
|
||||||
|
strbuf_addstr(&sb, prefix);
|
||||||
|
add_hpp_sort_string(&sb, hpp_sort_dimensions,
|
||||||
|
ARRAY_SIZE(hpp_sort_dimensions), &len);
|
||||||
|
add_sort_string(&sb, common_sort_dimensions,
|
||||||
|
ARRAY_SIZE(common_sort_dimensions), &len);
|
||||||
|
add_sort_string(&sb, bstack_sort_dimensions,
|
||||||
|
ARRAY_SIZE(bstack_sort_dimensions), &len);
|
||||||
|
add_sort_string(&sb, memory_sort_dimensions,
|
||||||
|
ARRAY_SIZE(memory_sort_dimensions), &len);
|
||||||
|
s = strbuf_detach(&sb, NULL);
|
||||||
|
strbuf_release(&sb);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
@ -296,6 +296,8 @@ void reset_output_field(void);
|
|||||||
void sort__setup_elide(FILE *fp);
|
void sort__setup_elide(FILE *fp);
|
||||||
void perf_hpp__set_elide(int idx, bool elide);
|
void perf_hpp__set_elide(int idx, bool elide);
|
||||||
|
|
||||||
|
const char *sort_help(const char *prefix);
|
||||||
|
|
||||||
int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
|
int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
|
||||||
|
|
||||||
bool is_strict_order(const char *order);
|
bool is_strict_order(const char *order);
|
||||||
|
Loading…
Reference in New Issue
Block a user