提交 74d5b588 编写于 作者: J Jaswinder Singh Rajput 提交者: Ingo Molnar

perf_counter tools: Introduce alias member in event_symbol

By introducing alias member in event_symbol :

1. duplicate lines are removed, like:
   cpu-cycles and cycles
   branch-instructions and branches
   context-switches and cs
   cpu-migrations and migrations

2. We can also add alias for another events.

Now ./perf list looks like :

List of pre-defined events (to be used in -e):

  cpu-cycles OR cycles                     [Hardware event]
  instructions                             [Hardware event]
  cache-references                         [Hardware event]
  cache-misses                             [Hardware event]
  branch-instructions OR branches          [Hardware event]
  branch-misses                            [Hardware event]
  bus-cycles                               [Hardware event]

  cpu-clock                                [Software event]
  task-clock                               [Software event]
  page-faults                              [Software event]
  faults                                   [Software event]
  minor-faults                             [Software event]
  major-faults                             [Software event]
  context-switches OR cs                   [Software event]
  cpu-migrations OR migrations             [Software event]

  rNNN                                     [raw hardware event descriptor]
Signed-off-by: NJaswinder Singh Rajput <jaswinderrajput@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1245669268.17153.8.camel@localhost.localdomain>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 51e26842
...@@ -16,32 +16,29 @@ struct event_symbol { ...@@ -16,32 +16,29 @@ struct event_symbol {
u8 type; u8 type;
u64 config; u64 config;
char *symbol; char *symbol;
char *alias;
}; };
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
static struct event_symbol event_symbols[] = { static struct event_symbol event_symbols[] = {
{ CHW(CPU_CYCLES), "cpu-cycles", }, { CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
{ CHW(CPU_CYCLES), "cycles", }, { CHW(INSTRUCTIONS), "instructions", "" },
{ CHW(INSTRUCTIONS), "instructions", }, { CHW(CACHE_REFERENCES), "cache-references", "" },
{ CHW(CACHE_REFERENCES), "cache-references", }, { CHW(CACHE_MISSES), "cache-misses", "" },
{ CHW(CACHE_MISSES), "cache-misses", }, { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
{ CHW(BRANCH_INSTRUCTIONS), "branch-instructions", }, { CHW(BRANCH_MISSES), "branch-misses", "" },
{ CHW(BRANCH_INSTRUCTIONS), "branches", }, { CHW(BUS_CYCLES), "bus-cycles", "" },
{ CHW(BRANCH_MISSES), "branch-misses", },
{ CHW(BUS_CYCLES), "bus-cycles", }, { CSW(CPU_CLOCK), "cpu-clock", "" },
{ CSW(TASK_CLOCK), "task-clock", "" },
{ CSW(CPU_CLOCK), "cpu-clock", }, { CSW(PAGE_FAULTS), "page-faults", "" },
{ CSW(TASK_CLOCK), "task-clock", }, { CSW(PAGE_FAULTS), "faults", "" },
{ CSW(PAGE_FAULTS), "page-faults", }, { CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
{ CSW(PAGE_FAULTS), "faults", }, { CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
{ CSW(PAGE_FAULTS_MIN), "minor-faults", }, { CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
{ CSW(PAGE_FAULTS_MAJ), "major-faults", }, { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
{ CSW(CONTEXT_SWITCHES), "context-switches", },
{ CSW(CONTEXT_SWITCHES), "cs", },
{ CSW(CPU_MIGRATIONS), "cpu-migrations", },
{ CSW(CPU_MIGRATIONS), "migrations", },
}; };
#define __PERF_COUNTER_FIELD(config, name) \ #define __PERF_COUNTER_FIELD(config, name) \
...@@ -196,6 +193,19 @@ static int parse_generic_hw_symbols(const char *str, struct perf_counter_attr *a ...@@ -196,6 +193,19 @@ static int parse_generic_hw_symbols(const char *str, struct perf_counter_attr *a
return 0; return 0;
} }
static int check_events(const char *str, unsigned int i)
{
if (!strncmp(str, event_symbols[i].symbol,
strlen(event_symbols[i].symbol)))
return 1;
if (strlen(event_symbols[i].alias))
if (!strncmp(str, event_symbols[i].alias,
strlen(event_symbols[i].alias)))
return 1;
return 0;
}
/* /*
* Each event can have multiple symbolic names. * Each event can have multiple symbolic names.
* Symbolic names are (almost) exactly matched. * Symbolic names are (almost) exactly matched.
...@@ -235,9 +245,7 @@ static int parse_event_symbols(const char *str, struct perf_counter_attr *attr) ...@@ -235,9 +245,7 @@ static int parse_event_symbols(const char *str, struct perf_counter_attr *attr)
} }
for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {
if (!strncmp(str, event_symbols[i].symbol, if (check_events(str, i)) {
strlen(event_symbols[i].symbol))) {
attr->type = event_symbols[i].type; attr->type = event_symbols[i].type;
attr->config = event_symbols[i].config; attr->config = event_symbols[i].config;
...@@ -289,6 +297,7 @@ void print_events(void) ...@@ -289,6 +297,7 @@ void print_events(void)
{ {
struct event_symbol *syms = event_symbols; struct event_symbol *syms = event_symbols;
unsigned int i, type, prev_type = -1; unsigned int i, type, prev_type = -1;
char name[40];
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "List of pre-defined events (to be used in -e):\n"); fprintf(stderr, "List of pre-defined events (to be used in -e):\n");
...@@ -301,14 +310,18 @@ void print_events(void) ...@@ -301,14 +310,18 @@ void print_events(void)
if (type != prev_type) if (type != prev_type)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, " %-30s [%s]\n", syms->symbol, if (strlen(syms->alias))
sprintf(name, "%s OR %s", syms->symbol, syms->alias);
else
strcpy(name, syms->symbol);
fprintf(stderr, " %-40s [%s]\n", name,
event_type_descriptors[type]); event_type_descriptors[type]);
prev_type = type; prev_type = type;
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, " %-30s [raw hardware event descriptor]\n", fprintf(stderr, " %-40s [raw hardware event descriptor]\n",
"rNNN"); "rNNN");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册