summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-06-06 12:24:17 +0200
committerIngo Molnar <mingo@elte.hu>2009-06-06 14:16:49 +0200
commit86847b62f0781ccc97a79936c9ed9dc818cff67b (patch)
treea55a8ea4a3e2c771322edc7aa01b1572c3a59c06 /Documentation
parent8326f44da090d6d304d29b9fdc7fb3e20889e329 (diff)
downloadlwn-86847b62f0781ccc97a79936c9ed9dc818cff67b.tar.gz
lwn-86847b62f0781ccc97a79936c9ed9dc818cff67b.zip
perf_counter tools: Add 'perf list' to list available events
perf list: List all the available event types which can be used in -e (--event) options. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
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
BUILTIN_OBJS += builtin-report.o
BUILTIN_OBJS += builtin-stat.o
BUILTIN_OBJS += builtin-top.o
+BUILTIN_OBJS += builtin-list.o
PERFLIBS = $(LIB_FILE)
EXTLIBS =
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 @@
+/*
+ * builtin-list.c
+ *
+ * Builtin list command: list all event types
+ *
+ * Copyright (C) 2009, Thomas Gleixner <tglx@linutronix.de>
+ * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
+ */
+#include "builtin.h"
+
+#include "perf.h"
+
+#include "util/parse-options.h"
+#include "util/parse-events.h"
+
+int cmd_list(int argc, const char **argv, const char *prefix)
+{
+ print_events();
+ return 0;
+}
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[] = {
NULL
};
-static char events_help_msg[EVENTS_HELP_MAX];
-
static const struct option options[] = {
OPT_CALLBACK('e', "event", NULL, "event",
- events_help_msg, parse_events),
+ "event selector. use 'perf list' to list available events",
+ parse_events),
OPT_INTEGER('p', "pid", &target_pid,
"record events on existing pid"),
OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -527,8 +526,6 @@ int cmd_record(int argc, const char **argv, const char *prefix)
{
int counter;
- create_events_help(events_help_msg);
-
argc = parse_options(argc, argv, options, record_usage, 0);
if (!argc && target_pid == -1 && !system_wide)
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[] = {
NULL
};
-static char events_help_msg[EVENTS_HELP_MAX];
-
static const struct option options[] = {
OPT_CALLBACK('e', "event", NULL, "event",
- events_help_msg, parse_events),
+ "event selector. use 'perf list' to list available events",
+ parse_events),
OPT_BOOLEAN('i', "inherit", &inherit,
"child tasks inherit counters"),
OPT_INTEGER('p', "pid", &target_pid,
"stat events on existing pid"),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
- OPT_BOOLEAN('l', "scale", &scale,
+ OPT_BOOLEAN('S', "scale", &scale,
"scale/normalize counters"),
OPT_END()
};
@@ -313,8 +312,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
{
page_size = sysconf(_SC_PAGE_SIZE);
- create_events_help(events_help_msg);
-
memcpy(attrs, default_attrs, sizeof(attrs));
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[] = {
NULL
};
-static char events_help_msg[EVENTS_HELP_MAX];
-
static const struct option options[] = {
OPT_CALLBACK('e', "event", NULL, "event",
- events_help_msg, parse_events),
+ "event selector. use 'perf list' to list available events",
+ parse_events),
OPT_INTEGER('c', "count", &default_interval,
"event period to sample"),
OPT_INTEGER('p', "pid", &target_pid,
@@ -648,8 +647,6 @@ int cmd_top(int argc, const char **argv, const char *prefix)
page_size = sysconf(_SC_PAGE_SIZE);
- create_events_help(events_help_msg);
-
argc = parse_options(argc, argv, options, top_usage, 0);
if (argc)
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);
extern int cmd_stat(int argc, const char **argv, const char *prefix);
extern int cmd_top(int argc, const char **argv, const char *prefix);
extern int cmd_version(int argc, const char **argv, const char *prefix);
+extern int cmd_list(int argc, const char **argv, const char *prefix);
+
#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)
const char *cmd = argv[0];
static struct cmd_struct commands[] = {
{ "help", cmd_help, 0 },
+ { "list", cmd_list, 0 },
{ "record", cmd_record, 0 },
{ "report", cmd_report, 0 },
{ "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:
return 0;
}
+static const char * const event_type_descriptors[] = {
+ "",
+ "Hardware event",
+ "Software event",
+ "Tracepoint event",
+ "Hardware cache event",
+};
+
/*
- * Create the help text for the event symbols:
+ * Print the help text for the event symbols:
*/
-void create_events_help(char *events_help_msg)
+void print_events(void)
{
- unsigned int i;
- char *str;
+ struct event_symbol *syms = event_symbols;
+ unsigned int i, type, prev_type = -1;
- str = events_help_msg;
+ fprintf(stderr, "\n");
+ fprintf(stderr, "List of pre-defined events (to be used in -e):\n");
- str += sprintf(str,
- "event name: [");
+ for (i = 0; i < ARRAY_SIZE(event_symbols); i++, syms++) {
+ type = syms->type + 1;
+ if (type > ARRAY_SIZE(event_type_descriptors))
+ type = 0;
- for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {
- int type, id;
-
- type = event_symbols[i].type;
- id = event_symbols[i].config;
+ if (type != prev_type)
+ fprintf(stderr, "\n");
- if (i)
- str += sprintf(str, "|");
+ fprintf(stderr, " %-30s [%s]\n", syms->symbol,
+ event_type_descriptors[type]);
- str += sprintf(str, "%s",
- event_symbols[i].symbol);
+ prev_type = type;
}
- str += sprintf(str, "|rNNN]");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " %-30s [raw hardware event descriptor]\n",
+ "rNNN");
+ fprintf(stderr, "\n");
+
+ exit(129);
}
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);
#define EVENTS_HELP_MAX (128*1024)
-extern void create_events_help(char *help_msg);
+extern void print_events(void);