aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-03-19 22:08:04 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:21 -0400
commit95bb3be1b3ca4a71cc168787b675d5b7852fc6be (patch)
treecee0056621c685a0eac79899325861e3c17fde58 /Documentation/perf_counter
parentf49012fad4ed2231c7380c0b1901122242b3eab0 (diff)
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: Wu Fengguang <fengguang.wu@intel.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter')
-rw-r--r--Documentation/perf_counter/kerneltop.c28
-rw-r--r--Documentation/perf_counter/perfcounters.h15
-rw-r--r--Documentation/perf_counter/perfstat.c8
3 files changed, 16 insertions, 35 deletions
diff --git a/Documentation/perf_counter/kerneltop.c b/Documentation/perf_counter/kerneltop.c
index fe70a2c92a8e..edc5b09fb586 100644
--- a/Documentation/perf_counter/kerneltop.c
+++ b/Documentation/perf_counter/kerneltop.c
@@ -86,13 +86,9 @@ const unsigned int default_count[] = {
86 10000, 86 10000,
87}; 87};
88 88
89static int nr_counters = -1;
90
91static __u64 count_filter = 100; 89static __u64 count_filter = 100;
92 90
93static int event_count[MAX_COUNTERS]; 91static int event_count[MAX_COUNTERS];
94static unsigned long event_id[MAX_COUNTERS];
95static int event_raw[MAX_COUNTERS];
96 92
97static int tid = -1; 93static int tid = -1;
98static int profile_cpu = -1; 94static int profile_cpu = -1;
@@ -125,7 +121,7 @@ static void display_help(void)
125 "KernelTop Options (up to %d event types can be specified at once):\n\n", 121 "KernelTop Options (up to %d event types can be specified at once):\n\n",
126 MAX_COUNTERS); 122 MAX_COUNTERS);
127 printf( 123 printf(
128 " -e EID --event_id=EID # event type ID [default: 0]\n" 124 " -e EID --event=EID # event type ID [default: 0]\n"
129 " 0: CPU cycles\n" 125 " 0: CPU cycles\n"
130 " 1: instructions\n" 126 " 1: instructions\n"
131 " 2: cache accesses\n" 127 " 2: cache accesses\n"
@@ -160,7 +156,7 @@ static void process_options(int argc, char *argv[])
160 {"cpu", required_argument, NULL, 'C'}, 156 {"cpu", required_argument, NULL, 'C'},
161 {"delay", required_argument, NULL, 'd'}, 157 {"delay", required_argument, NULL, 'd'},
162 {"dump_symtab", no_argument, NULL, 'D'}, 158 {"dump_symtab", no_argument, NULL, 'D'},
163 {"event_id", required_argument, NULL, 'e'}, 159 {"event", required_argument, NULL, 'e'},
164 {"filter", required_argument, NULL, 'f'}, 160 {"filter", required_argument, NULL, 'f'},
165 {"group", required_argument, NULL, 'g'}, 161 {"group", required_argument, NULL, 'g'},
166 {"help", no_argument, NULL, 'h'}, 162 {"help", no_argument, NULL, 'h'},
@@ -178,8 +174,6 @@ static void process_options(int argc, char *argv[])
178 174
179 switch (c) { 175 switch (c) {
180 case 'c': 176 case 'c':
181 if (nr_counters == -1)
182 nr_counters = 0;
183 event_count[nr_counters] = atoi(optarg); break; 177 event_count[nr_counters] = atoi(optarg); break;
184 case 'C': 178 case 'C':
185 /* CPU and PID are mutually exclusive */ 179 /* CPU and PID are mutually exclusive */
@@ -192,18 +186,7 @@ static void process_options(int argc, char *argv[])
192 case 'd': delay_secs = atoi(optarg); break; 186 case 'd': delay_secs = atoi(optarg); break;
193 case 'D': dump_symtab = 1; break; 187 case 'D': dump_symtab = 1; break;
194 188
195 case 'e': 189 case 'e': error = parse_events(optarg); break;
196 nr_counters++;
197 if (nr_counters == MAX_COUNTERS) {
198 error = 1;
199 break;
200 }
201 if (*optarg == 'r') {
202 event_raw[nr_counters] = 1;
203 ++optarg;
204 }
205 event_id[nr_counters] = strtol(optarg, NULL, 16);
206 break;
207 190
208 case 'f': count_filter = atoi(optarg); break; 191 case 'f': count_filter = atoi(optarg); break;
209 case 'g': group = atoi(optarg); break; 192 case 'g': group = atoi(optarg); break;
@@ -226,9 +209,10 @@ static void process_options(int argc, char *argv[])
226 if (error) 209 if (error)
227 display_help(); 210 display_help();
228 211
229 nr_counters++; 212 if (!nr_counters) {
230 if (nr_counters < 1)
231 nr_counters = 1; 213 nr_counters = 1;
214 event_id[0] = 0;
215 }
232 216
233 for (counter = 0; counter < nr_counters; counter++) { 217 for (counter = 0; counter < nr_counters; counter++) {
234 if (event_count[counter]) 218 if (event_count[counter])
diff --git a/Documentation/perf_counter/perfcounters.h b/Documentation/perf_counter/perfcounters.h
index 0f3764aa52ab..99a90d833e12 100644
--- a/Documentation/perf_counter/perfcounters.h
+++ b/Documentation/perf_counter/perfcounters.h
@@ -143,6 +143,10 @@ asmlinkage int sys_perf_counter_open(
143 return ret; 143 return ret;
144} 144}
145 145
146static int nr_counters = 0;
147static long event_id[MAX_COUNTERS] = { -2, -5, -4, -3, 0, 1, 2, 3};
148static int event_raw[MAX_COUNTERS];
149
146static char *hw_event_names [] = { 150static char *hw_event_names [] = {
147 "CPU cycles", 151 "CPU cycles",
148 "instructions", 152 "instructions",
@@ -235,14 +239,13 @@ static int match_event_symbols(char *str)
235 return PERF_HW_EVENTS_MAX; 239 return PERF_HW_EVENTS_MAX;
236} 240}
237 241
238static void parse_events(char *str) 242static int parse_events(char *str)
239{ 243{
240 int type, raw; 244 int type, raw;
241 245
242again: 246again:
243 nr_counters++;
244 if (nr_counters == MAX_COUNTERS) 247 if (nr_counters == MAX_COUNTERS)
245 display_help(); 248 return -1;
246 249
247 raw = 0; 250 raw = 0;
248 if (*str == 'r') { 251 if (*str == 'r') {
@@ -252,16 +255,18 @@ again:
252 } else { 255 } else {
253 type = match_event_symbols(str); 256 type = match_event_symbols(str);
254 if (!type_valid(type)) 257 if (!type_valid(type))
255 display_help(); 258 return -1;
256 } 259 }
257 260
258 event_id[nr_counters] = type; 261 event_id[nr_counters] = type;
259 event_raw[nr_counters] = raw; 262 event_raw[nr_counters] = raw;
263 nr_counters++;
260 264
261 str = strstr(str, ","); 265 str = strstr(str, ",");
262 if (str) { 266 if (str) {
263 str++; 267 str++;
264 goto again; 268 goto again;
265 } 269 }
266}
267 270
271 return 0;
272}
diff --git a/Documentation/perf_counter/perfstat.c b/Documentation/perf_counter/perfstat.c
index 3364dcb9dd9d..fd594468e655 100644
--- a/Documentation/perf_counter/perfstat.c
+++ b/Documentation/perf_counter/perfstat.c
@@ -54,14 +54,8 @@
54 54
55#include "perfcounters.h" 55#include "perfcounters.h"
56 56
57static int nr_counters = 0;
58static int nr_cpus = 0; 57static int nr_cpus = 0;
59 58
60static int event_id[MAX_COUNTERS] =
61 { -2, -5, -4, -3, 0, 1, 2, 3};
62
63static int event_raw[MAX_COUNTERS];
64
65static int system_wide = 0; 59static int system_wide = 0;
66 60
67static void display_help(void) 61static void display_help(void)
@@ -127,8 +121,6 @@ static void process_options(int argc, char *argv[])
127 121
128 if (!nr_counters) 122 if (!nr_counters)
129 nr_counters = 8; 123 nr_counters = 8;
130 else
131 nr_counters++;
132 return; 124 return;
133 125
134err: 126err: