aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/perf_counter/Makefile1
-rw-r--r--Documentation/perf_counter/builtin-list.c20
-rw-r--r--Documentation/perf_counter/builtin-record.c7
-rw-r--r--Documentation/perf_counter/builtin-stat.c9
-rw-r--r--Documentation/perf_counter/builtin-top.c7
-rw-r--r--Documentation/perf_counter/builtin.h2
-rw-r--r--Documentation/perf_counter/perf.c1
-rw-r--r--Documentation/perf_counter/util/parse-events.c46
-rw-r--r--Documentation/perf_counter/util/parse-events.h2
9 files changed, 61 insertions, 34 deletions
diff --git a/Documentation/perf_counter/Makefile b/Documentation/perf_counter/Makefile
index 5b99f04df812..32c0bb21a328 100644
--- a/Documentation/perf_counter/Makefile
+++ b/Documentation/perf_counter/Makefile
@@ -328,6 +328,7 @@ BUILTIN_OBJS += builtin-record.o
328BUILTIN_OBJS += builtin-report.o 328BUILTIN_OBJS += builtin-report.o
329BUILTIN_OBJS += builtin-stat.o 329BUILTIN_OBJS += builtin-stat.o
330BUILTIN_OBJS += builtin-top.o 330BUILTIN_OBJS += builtin-top.o
331BUILTIN_OBJS += builtin-list.o
331 332
332PERFLIBS = $(LIB_FILE) 333PERFLIBS = $(LIB_FILE)
333EXTLIBS = 334EXTLIBS =
diff --git a/Documentation/perf_counter/builtin-list.c b/Documentation/perf_counter/builtin-list.c
new file mode 100644
index 000000000000..fe60e37c96ef
--- /dev/null
+++ b/Documentation/perf_counter/builtin-list.c
@@ -0,0 +1,20 @@
1/*
2 * builtin-list.c
3 *
4 * Builtin list command: list all event types
5 *
6 * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de>
7 * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
8 */
9#include "builtin.h"
10
11#include "perf.h"
12
13#include "util/parse-options.h"
14#include "util/parse-events.h"
15
16int cmd_list(int argc, const char **argv, const char *prefix)
17{
18 print_events();
19 return 0;
20}
diff --git a/Documentation/perf_counter/builtin-record.c b/Documentation/perf_counter/builtin-record.c
index 130fd88266bb..aeab9c4b15e4 100644
--- a/Documentation/perf_counter/builtin-record.c
+++ b/Documentation/perf_counter/builtin-record.c
@@ -495,11 +495,10 @@ static const char * const record_usage[] = {
495 NULL 495 NULL
496}; 496};
497 497
498static char events_help_msg[EVENTS_HELP_MAX];
499
500static const struct option options[] = { 498static const struct option options[] = {
501 OPT_CALLBACK('e', "event", NULL, "event", 499 OPT_CALLBACK('e', "event", NULL, "event",
502 events_help_msg, parse_events), 500 "event selector. use 'perf list' to list available events",
501 parse_events),
503 OPT_INTEGER('p', "pid", &target_pid, 502 OPT_INTEGER('p', "pid", &target_pid,
504 "record events on existing pid"), 503 "record events on existing pid"),
505 OPT_INTEGER('r', "realtime", &realtime_prio, 504 OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -527,8 +526,6 @@ int cmd_record(int argc, const char **argv, const char *prefix)
527{ 526{
528 int counter; 527 int counter;
529 528
530 create_events_help(events_help_msg);
531
532 argc = parse_options(argc, argv, options, record_usage, 0); 529 argc = parse_options(argc, argv, options, record_usage, 0);
533 if (!argc && target_pid == -1 && !system_wide) 530 if (!argc && target_pid == -1 && !system_wide)
534 usage_with_options(record_usage, options); 531 usage_with_options(record_usage, options);
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c
index 9711e5524233..2cbf5a189589 100644
--- a/Documentation/perf_counter/builtin-stat.c
+++ b/Documentation/perf_counter/builtin-stat.c
@@ -293,18 +293,17 @@ static const char * const stat_usage[] = {
293 NULL 293 NULL
294}; 294};
295 295
296static char events_help_msg[EVENTS_HELP_MAX];
297
298static const struct option options[] = { 296static const struct option options[] = {
299 OPT_CALLBACK('e', "event", NULL, "event", 297 OPT_CALLBACK('e', "event", NULL, "event",
300 events_help_msg, parse_events), 298 "event selector. use 'perf list' to list available events",
299 parse_events),
301 OPT_BOOLEAN('i', "inherit", &inherit, 300 OPT_BOOLEAN('i', "inherit", &inherit,
302 "child tasks inherit counters"), 301 "child tasks inherit counters"),
303 OPT_INTEGER('p', "pid", &target_pid, 302 OPT_INTEGER('p', "pid", &target_pid,
304 "stat events on existing pid"), 303 "stat events on existing pid"),
305 OPT_BOOLEAN('a', "all-cpus", &system_wide, 304 OPT_BOOLEAN('a', "all-cpus", &system_wide,
306 "system-wide collection from all CPUs"), 305 "system-wide collection from all CPUs"),
307 OPT_BOOLEAN('l', "scale", &scale, 306 OPT_BOOLEAN('S', "scale", &scale,
308 "scale/normalize counters"), 307 "scale/normalize counters"),
309 OPT_END() 308 OPT_END()
310}; 309};
@@ -313,8 +312,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
313{ 312{
314 page_size = sysconf(_SC_PAGE_SIZE); 313 page_size = sysconf(_SC_PAGE_SIZE);
315 314
316 create_events_help(events_help_msg);
317
318 memcpy(attrs, default_attrs, sizeof(attrs)); 315 memcpy(attrs, default_attrs, sizeof(attrs));
319 316
320 argc = parse_options(argc, argv, options, stat_usage, 0); 317 argc = parse_options(argc, argv, options, stat_usage, 0);
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index 98a6d53e17b3..f2e7312f85c9 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -606,11 +606,10 @@ static const char * const top_usage[] = {
606 NULL 606 NULL
607}; 607};
608 608
609static char events_help_msg[EVENTS_HELP_MAX];
610
611static const struct option options[] = { 609static const struct option options[] = {
612 OPT_CALLBACK('e', "event", NULL, "event", 610 OPT_CALLBACK('e', "event", NULL, "event",
613 events_help_msg, parse_events), 611 "event selector. use 'perf list' to list available events",
612 parse_events),
614 OPT_INTEGER('c', "count", &default_interval, 613 OPT_INTEGER('c', "count", &default_interval,
615 "event period to sample"), 614 "event period to sample"),
616 OPT_INTEGER('p', "pid", &target_pid, 615 OPT_INTEGER('p', "pid", &target_pid,
@@ -648,8 +647,6 @@ int cmd_top(int argc, const char **argv, const char *prefix)
648 647
649 page_size = sysconf(_SC_PAGE_SIZE); 648 page_size = sysconf(_SC_PAGE_SIZE);
650 649
651 create_events_help(events_help_msg);
652
653 argc = parse_options(argc, argv, options, top_usage, 0); 650 argc = parse_options(argc, argv, options, top_usage, 0);
654 if (argc) 651 if (argc)
655 usage_with_options(top_usage, options); 652 usage_with_options(top_usage, options);
diff --git a/Documentation/perf_counter/builtin.h b/Documentation/perf_counter/builtin.h
index 5bfea57d33fe..e7de47da8581 100644
--- a/Documentation/perf_counter/builtin.h
+++ b/Documentation/perf_counter/builtin.h
@@ -20,4 +20,6 @@ extern int cmd_report(int argc, const char **argv, const char *prefix);
20extern int cmd_stat(int argc, const char **argv, const char *prefix); 20extern int cmd_stat(int argc, const char **argv, const char *prefix);
21extern int cmd_top(int argc, const char **argv, const char *prefix); 21extern int cmd_top(int argc, const char **argv, const char *prefix);
22extern int cmd_version(int argc, const char **argv, const char *prefix); 22extern int cmd_version(int argc, const char **argv, const char *prefix);
23extern int cmd_list(int argc, const char **argv, const char *prefix);
24
23#endif 25#endif
diff --git a/Documentation/perf_counter/perf.c b/Documentation/perf_counter/perf.c
index ec7edb7fbe29..9ac75657a180 100644
--- a/Documentation/perf_counter/perf.c
+++ b/Documentation/perf_counter/perf.c
@@ -258,6 +258,7 @@ static void handle_internal_command(int argc, const char **argv)
258 const char *cmd = argv[0]; 258 const char *cmd = argv[0];
259 static struct cmd_struct commands[] = { 259 static struct cmd_struct commands[] = {
260 { "help", cmd_help, 0 }, 260 { "help", cmd_help, 0 },
261 { "list", cmd_list, 0 },
261 { "record", cmd_record, 0 }, 262 { "record", cmd_record, 0 },
262 { "report", cmd_report, 0 }, 263 { "report", cmd_report, 0 },
263 { "stat", cmd_stat, 0 }, 264 { "stat", cmd_stat, 0 },
diff --git a/Documentation/perf_counter/util/parse-events.c b/Documentation/perf_counter/util/parse-events.c
index de9a77c47151..150fbd262714 100644
--- a/Documentation/perf_counter/util/parse-events.c
+++ b/Documentation/perf_counter/util/parse-events.c
@@ -274,31 +274,43 @@ again:
274 return 0; 274 return 0;
275} 275}
276 276
277static const char * const event_type_descriptors[] = {
278 "",
279 "Hardware event",
280 "Software event",
281 "Tracepoint event",
282 "Hardware cache event",
283};
284
277/* 285/*
278 * Create the help text for the event symbols: 286 * Print the help text for the event symbols:
279 */ 287 */
280void create_events_help(char *events_help_msg) 288void print_events(void)
281{ 289{
282 unsigned int i; 290 struct event_symbol *syms = event_symbols;
283 char *str; 291 unsigned int i, type, prev_type = -1;
284 292
285 str = events_help_msg; 293 fprintf(stderr, "\n");
294 fprintf(stderr, "List of pre-defined events (to be used in -e):\n");
286 295
287 str += sprintf(str, 296 for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
288 "event name: ["); 297 type = syms->type + 1;
298 if (type > ARRAY_SIZE(event_type_descriptors))
299 type = 0;
289 300
290 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { 301 if (type != prev_type)
291 int type, id; 302 fprintf(stderr, "\n");
292
293 type = event_symbols[i].type;
294 id = event_symbols[i].config;
295 303
296 if (i) 304 fprintf(stderr, " %-30s [%s]\n", syms->symbol,
297 str += sprintf(str, "|"); 305 event_type_descriptors[type]);
298 306
299 str += sprintf(str, "%s", 307 prev_type = type;
300 event_symbols[i].symbol);
301 } 308 }
302 309
303 str += sprintf(str, "|rNNN]"); 310 fprintf(stderr, "\n");
311 fprintf(stderr, " %-30s [raw hardware event descriptor]\n",
312 "rNNN");
313 fprintf(stderr, "\n");
314
315 exit(129);
304} 316}
diff --git a/Documentation/perf_counter/util/parse-events.h b/Documentation/perf_counter/util/parse-events.h
index 542971c495bd..e3d552908e60 100644
--- a/Documentation/perf_counter/util/parse-events.h
+++ b/Documentation/perf_counter/util/parse-events.h
@@ -13,5 +13,5 @@ extern int parse_events(const struct option *opt, const char *str, int unset);
13 13
14#define EVENTS_HELP_MAX (128*1024) 14#define EVENTS_HELP_MAX (128*1024)
15 15
16extern void create_events_help(char *help_msg); 16extern void print_events(void);
17 17