Commit b027cc6f authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf c2c: Fix 'perf c2c record -e list' to show the default events used

When the event is passed as list, the default events should be listed as
per 'perf mem record -e list'. Previous behavior is:

  $ perf c2c record -e list
  failed: event 'list' not found, use '-e list' to get list of available events

   Usage: perf c2c record [<options>] [<command>]
      or: perf c2c record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. Use 'perf mem record -e list' to list available events
  $

New behavior:

  $ perf c2c record -e list
  ldlat-loads  : available
  ldlat-stores : available

v3: is a rebase.
v2: addresses review comments by Jiri Olsa.

https://lore.kernel.org/lkml/20191127081844.GH32367@krava/Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200507220604.3391-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 63b5930f
......@@ -40,7 +40,7 @@ RECORD OPTIONS
--------------
-e::
--event=::
Select the PMU event. Use 'perf mem record -e list'
Select the PMU event. Use 'perf c2c record -e list'
to list available events.
-v::
......
......@@ -2887,8 +2887,15 @@ static int parse_record_events(const struct option *opt,
{
bool *event_set = (bool *) opt->value;
if (!strcmp(str, "list")) {
perf_mem_events__list();
exit(0);
}
if (perf_mem_events__parse(str))
exit(-1);
*event_set = true;
return perf_mem_events__parse(str);
return 0;
}
......
......@@ -38,26 +38,16 @@ static int parse_record_events(const struct option *opt,
const char *str, int unset __maybe_unused)
{
struct perf_mem *mem = *(struct perf_mem **)opt->value;
int j;
if (strcmp(str, "list")) {
if (!perf_mem_events__parse(str)) {
mem->operation = 0;
return 0;
if (!strcmp(str, "list")) {
perf_mem_events__list();
exit(0);
}
if (perf_mem_events__parse(str))
exit(-1);
}
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
struct perf_mem_event *e = &perf_mem_events[j];
fprintf(stderr, "%-13s%-*s%s\n",
e->tag,
verbose > 0 ? 25 : 0,
verbose > 0 ? perf_mem_events__name(j) : "",
e->supported ? ": available" : "");
}
exit(0);
mem->operation = 0;
return 0;
}
static const char * const __usage[] = {
......
......@@ -103,6 +103,21 @@ int perf_mem_events__init(void)
return found ? 0 : -ENOENT;
}
void perf_mem_events__list(void)
{
int j;
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
struct perf_mem_event *e = &perf_mem_events[j];
fprintf(stderr, "%-13s%-*s%s\n",
e->tag,
verbose > 0 ? 25 : 0,
verbose > 0 ? perf_mem_events__name(j) : "",
e->supported ? ": available" : "");
}
}
static const char * const tlb_access[] = {
"N/A",
"HIT",
......
......@@ -39,6 +39,8 @@ int perf_mem_events__init(void);
char *perf_mem_events__name(int i);
void perf_mem_events__list(void);
struct mem_info;
int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment