Commit 95bb3be1 authored by Wu Fengguang's avatar Wu Fengguang Committed by Ingo Molnar

perf_counter tools: support symbolic event names in kerneltop

- kerneltop: --event_id => --event
- kerneltop: can accept SW event types now
- perfstat: it used to implicitly add event -2(task-clock),
	    the new code no longer does this. Shall we?
Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f49012fa
...@@ -86,13 +86,9 @@ const unsigned int default_count[] = { ...@@ -86,13 +86,9 @@ const unsigned int default_count[] = {
10000, 10000,
}; };
static int nr_counters = -1;
static __u64 count_filter = 100; static __u64 count_filter = 100;
static int event_count[MAX_COUNTERS]; static int event_count[MAX_COUNTERS];
static unsigned long event_id[MAX_COUNTERS];
static int event_raw[MAX_COUNTERS];
static int tid = -1; static int tid = -1;
static int profile_cpu = -1; static int profile_cpu = -1;
...@@ -125,7 +121,7 @@ static void display_help(void) ...@@ -125,7 +121,7 @@ static void display_help(void)
"KernelTop Options (up to %d event types can be specified at once):\n\n", "KernelTop Options (up to %d event types can be specified at once):\n\n",
MAX_COUNTERS); MAX_COUNTERS);
printf( printf(
" -e EID --event_id=EID # event type ID [default: 0]\n" " -e EID --event=EID # event type ID [default: 0]\n"
" 0: CPU cycles\n" " 0: CPU cycles\n"
" 1: instructions\n" " 1: instructions\n"
" 2: cache accesses\n" " 2: cache accesses\n"
...@@ -160,7 +156,7 @@ static void process_options(int argc, char *argv[]) ...@@ -160,7 +156,7 @@ static void process_options(int argc, char *argv[])
{"cpu", required_argument, NULL, 'C'}, {"cpu", required_argument, NULL, 'C'},
{"delay", required_argument, NULL, 'd'}, {"delay", required_argument, NULL, 'd'},
{"dump_symtab", no_argument, NULL, 'D'}, {"dump_symtab", no_argument, NULL, 'D'},
{"event_id", required_argument, NULL, 'e'}, {"event", required_argument, NULL, 'e'},
{"filter", required_argument, NULL, 'f'}, {"filter", required_argument, NULL, 'f'},
{"group", required_argument, NULL, 'g'}, {"group", required_argument, NULL, 'g'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
...@@ -178,8 +174,6 @@ static void process_options(int argc, char *argv[]) ...@@ -178,8 +174,6 @@ static void process_options(int argc, char *argv[])
switch (c) { switch (c) {
case 'c': case 'c':
if (nr_counters == -1)
nr_counters = 0;
event_count[nr_counters] = atoi(optarg); break; event_count[nr_counters] = atoi(optarg); break;
case 'C': case 'C':
/* CPU and PID are mutually exclusive */ /* CPU and PID are mutually exclusive */
...@@ -192,18 +186,7 @@ static void process_options(int argc, char *argv[]) ...@@ -192,18 +186,7 @@ static void process_options(int argc, char *argv[])
case 'd': delay_secs = atoi(optarg); break; case 'd': delay_secs = atoi(optarg); break;
case 'D': dump_symtab = 1; break; case 'D': dump_symtab = 1; break;
case 'e': case 'e': error = parse_events(optarg); break;
nr_counters++;
if (nr_counters == MAX_COUNTERS) {
error = 1;
break;
}
if (*optarg == 'r') {
event_raw[nr_counters] = 1;
++optarg;
}
event_id[nr_counters] = strtol(optarg, NULL, 16);
break;
case 'f': count_filter = atoi(optarg); break; case 'f': count_filter = atoi(optarg); break;
case 'g': group = atoi(optarg); break; case 'g': group = atoi(optarg); break;
...@@ -226,9 +209,10 @@ static void process_options(int argc, char *argv[]) ...@@ -226,9 +209,10 @@ static void process_options(int argc, char *argv[])
if (error) if (error)
display_help(); display_help();
nr_counters++; if (!nr_counters) {
if (nr_counters < 1)
nr_counters = 1; nr_counters = 1;
event_id[0] = 0;
}
for (counter = 0; counter < nr_counters; counter++) { for (counter = 0; counter < nr_counters; counter++) {
if (event_count[counter]) if (event_count[counter])
......
...@@ -143,6 +143,10 @@ asmlinkage int sys_perf_counter_open( ...@@ -143,6 +143,10 @@ asmlinkage int sys_perf_counter_open(
return ret; return ret;
} }
static int nr_counters = 0;
static long event_id[MAX_COUNTERS] = { -2, -5, -4, -3, 0, 1, 2, 3};
static int event_raw[MAX_COUNTERS];
static char *hw_event_names [] = { static char *hw_event_names [] = {
"CPU cycles", "CPU cycles",
"instructions", "instructions",
...@@ -235,14 +239,13 @@ static int match_event_symbols(char *str) ...@@ -235,14 +239,13 @@ static int match_event_symbols(char *str)
return PERF_HW_EVENTS_MAX; return PERF_HW_EVENTS_MAX;
} }
static void parse_events(char *str) static int parse_events(char *str)
{ {
int type, raw; int type, raw;
again: again:
nr_counters++;
if (nr_counters == MAX_COUNTERS) if (nr_counters == MAX_COUNTERS)
display_help(); return -1;
raw = 0; raw = 0;
if (*str == 'r') { if (*str == 'r') {
...@@ -252,16 +255,18 @@ static void parse_events(char *str) ...@@ -252,16 +255,18 @@ static void parse_events(char *str)
} else { } else {
type = match_event_symbols(str); type = match_event_symbols(str);
if (!type_valid(type)) if (!type_valid(type))
display_help(); return -1;
} }
event_id[nr_counters] = type; event_id[nr_counters] = type;
event_raw[nr_counters] = raw; event_raw[nr_counters] = raw;
nr_counters++;
str = strstr(str, ","); str = strstr(str, ",");
if (str) { if (str) {
str++; str++;
goto again; goto again;
} }
}
return 0;
}
...@@ -54,14 +54,8 @@ ...@@ -54,14 +54,8 @@
#include "perfcounters.h" #include "perfcounters.h"
static int nr_counters = 0;
static int nr_cpus = 0; static int nr_cpus = 0;
static int event_id[MAX_COUNTERS] =
{ -2, -5, -4, -3, 0, 1, 2, 3};
static int event_raw[MAX_COUNTERS];
static int system_wide = 0; static int system_wide = 0;
static void display_help(void) static void display_help(void)
...@@ -127,8 +121,6 @@ static void process_options(int argc, char *argv[]) ...@@ -127,8 +121,6 @@ static void process_options(int argc, char *argv[])
if (!nr_counters) if (!nr_counters)
nr_counters = 8; nr_counters = 8;
else
nr_counters++;
return; return;
err: err:
......
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