From 8f707d843c2f4023490a873dbc182f632a3a5906 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 15 Mar 2012 20:09:16 +0100 Subject: perf tools: Add config options support for event parsing Adding a new rule to the event grammar to be able to specify values of additional attributes of symbolic event. The new syntax for event symbolic definition is: event_legacy_symbol: PE_NAME_SYM '/' event_config '/' | PE_NAME_SYM sep_slash_dc event_config: event_config ',' event_term | event_term event_term: PE_NAME '=' PE_NAME | PE_NAME '=' PE_VALUE PE_NAME sep_slash_dc: '/' | ':' | At the moment the config options are hardcoded to be used for legacy symbol events to define several perf_event_attr fields. It is: 'config' to define perf_event_attr::config 'config1' to define perf_event_attr::config1 'config2' to define perf_event_attr::config2 'period' to define perf_event_attr::sample_period Legacy events could be now specified as: cycles/period=100000/ If term is specified without the value assignment, then 1 is assigned by default. Acked-by: Peter Zijlstra Signed-off-by: Jiri Olsa Link: http://lkml.kernel.org/n/tip-mgkavww9790jbt2jdkooyv4q@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.y | 94 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 6 deletions(-) (limited to 'tools/perf/util/parse-events.y') diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 4b4459e67a0a..c88c08e4e79d 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -23,7 +23,7 @@ do { \ %} -%token PE_VALUE PE_VALUE_SYM PE_RAW +%token PE_VALUE PE_VALUE_SYM PE_RAW PE_TERM %token PE_NAME %token PE_MODIFIER_EVENT PE_MODIFIER_BP %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT @@ -32,16 +32,21 @@ do { \ %type PE_VALUE %type PE_VALUE_SYM %type PE_RAW +%type PE_TERM %type PE_NAME %type PE_NAME_CACHE_TYPE %type PE_NAME_CACHE_OP_RESULT %type PE_MODIFIER_EVENT %type PE_MODIFIER_BP +%type event_config +%type event_term %union { char *str; unsigned long num; + struct list_head *head; + struct parse_events__term *term; } %% @@ -56,7 +61,7 @@ event_def PE_MODIFIER_EVENT | event_def -event_def: event_legacy_symbol sep_dc | +event_def: event_legacy_symbol | event_legacy_cache sep_dc | event_legacy_mem | event_legacy_tracepoint sep_dc | @@ -64,12 +69,21 @@ event_def: event_legacy_symbol sep_dc | event_legacy_raw sep_dc event_legacy_symbol: -PE_VALUE_SYM +PE_VALUE_SYM '/' event_config '/' { int type = $1 >> 16; int config = $1 & 255; - ABORT_ON(parse_events_add_numeric(list, idx, type, config)); + ABORT_ON(parse_events_add_numeric(list, idx, type, config, $3)); + parse_events__free_terms($3); +} +| +PE_VALUE_SYM sep_slash_dc +{ + int type = $1 >> 16; + int config = $1 & 255; + + ABORT_ON(parse_events_add_numeric(list, idx, type, config, NULL)); } event_legacy_cache: @@ -108,17 +122,85 @@ PE_NAME ':' PE_NAME event_legacy_numeric: PE_VALUE ':' PE_VALUE { - ABORT_ON(parse_events_add_numeric(list, idx, $1, $3)); + ABORT_ON(parse_events_add_numeric(list, idx, $1, $3, NULL)); } event_legacy_raw: PE_RAW { - ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1)); + ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1, NULL)); +} + +event_config: +event_config ',' event_term +{ + struct list_head *head = $1; + struct parse_events__term *term = $3; + + ABORT_ON(!head); + list_add_tail(&term->list, head); + $$ = $1; +} +| +event_term +{ + struct list_head *head = malloc(sizeof(*head)); + struct parse_events__term *term = $1; + + ABORT_ON(!head); + INIT_LIST_HEAD(head); + list_add_tail(&term->list, head); + $$ = head; +} + +event_term: +PE_NAME '=' PE_NAME +{ + struct parse_events__term *term; + + ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR, + $1, $3, 0)); + $$ = term; +} +| +PE_NAME '=' PE_VALUE +{ + struct parse_events__term *term; + + ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM, + $1, NULL, $3)); + $$ = term; +} +| +PE_NAME +{ + struct parse_events__term *term; + + ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM, + $1, NULL, 1)); + $$ = term; +} +| +PE_TERM '=' PE_VALUE +{ + struct parse_events__term *term; + + ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, $3)); + $$ = term; +} +| +PE_TERM +{ + struct parse_events__term *term; + + ABORT_ON(parse_events__new_term(&term, $1, NULL, NULL, 1)); + $$ = term; } sep_dc: ':' | +sep_slash_dc: '/' | ':' | + %% void parse_events_error(struct list_head *list __used, int *idx __used, -- cgit v1.2.3-59-g8ed1b