aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-03-15 15:09:18 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-03-16 13:30:13 -0400
commit5f537a26590e696466aae7f41e6b77e92c8486d1 (patch)
tree6946ba5b2a4cc1133ab11d8a81c37465f794e655 /tools/perf/util/parse-events.c
parentcd82a32e9924d3a82bd27f830755d23e4ded25bc (diff)
perf tools: Add support to specify pmu style event
Added new event rule to the event definition grammar: event_def: event_pmu | ... event_pmu: PE_NAME '/' event_config '/' Using this rule, event could be now specified like: cpu/config=1,config1=2,config2=3/u where pmu name 'cpu' is looked up via following path: ${sysfs_mount}/bus/event_source/devices/${pmu} and config options are bound to the pmu's format definiton: ${sysfs_mount}/bus/event_source/devices/${pmu}/format The hardcoded config options still stays and have precedence over any format field defined with same name. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-50d8nr94f8k4wkezutrxvthe@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 59f5cf64ef70..bec1cc6a1f38 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -12,6 +12,7 @@
12#include "header.h" 12#include "header.h"
13#include "debugfs.h" 13#include "debugfs.h"
14#include "parse-events-flex.h" 14#include "parse-events-flex.h"
15#include "pmu.h"
15 16
16#define MAX_NAME_LEN 100 17#define MAX_NAME_LEN 100
17 18
@@ -646,6 +647,30 @@ int parse_events_add_numeric(struct list_head *list, int *idx,
646 (char *) __event_name(type, config)); 647 (char *) __event_name(type, config));
647} 648}
648 649
650int parse_events_add_pmu(struct list_head *list, int *idx,
651 char *name, struct list_head *head_config)
652{
653 struct perf_event_attr attr;
654 struct perf_pmu *pmu;
655
656 pmu = perf_pmu__find(name);
657 if (!pmu)
658 return -EINVAL;
659
660 memset(&attr, 0, sizeof(attr));
661
662 /*
663 * Configure hardcoded terms first, no need to check
664 * return value when called with fail == 0 ;)
665 */
666 config_attr(&attr, head_config, 0);
667
668 if (perf_pmu__config(pmu, &attr, head_config))
669 return -EINVAL;
670
671 return add_event(list, idx, &attr, (char *) "pmu");
672}
673
649int parse_events_modifier(struct list_head *list, char *str) 674int parse_events_modifier(struct list_head *list, char *str)
650{ 675{
651 struct perf_evsel *evsel; 676 struct perf_evsel *evsel;
@@ -957,8 +982,12 @@ void print_events(const char *event_glob)
957 982
958 printf("\n"); 983 printf("\n");
959 printf(" %-50s [%s]\n", 984 printf(" %-50s [%s]\n",
960 "rNNN (see 'perf list --help' on how to encode it)", 985 "rNNN",
986 event_type_descriptors[PERF_TYPE_RAW]);
987 printf(" %-50s [%s]\n",
988 "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
961 event_type_descriptors[PERF_TYPE_RAW]); 989 event_type_descriptors[PERF_TYPE_RAW]);
990 printf(" (see 'perf list --help' on how to encode it)\n");
962 printf("\n"); 991 printf("\n");
963 992
964 printf(" %-50s [%s]\n", 993 printf(" %-50s [%s]\n",