Commit 0b8891a8 authored by He Kuang's avatar He Kuang Committed by Arnaldo Carvalho de Melo

perf tools: Adds the config_term callback for different type events

Currently, function config_term() is used for checking config terms of
all types of events, while unknown terms is not reported as an error
because pmu events have valid terms in sysfs.

But this is wrong when unknown terms are specificed to hw/sw events.
This patch Adds the config_term callback so we can use separate check
routines for each type of events.
Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1443412336-120050-1-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ba11ba65
...@@ -599,7 +599,11 @@ static int check_type_val(struct parse_events_term *term, ...@@ -599,7 +599,11 @@ static int check_type_val(struct parse_events_term *term,
return -EINVAL; return -EINVAL;
} }
static int config_term(struct perf_event_attr *attr, typedef int config_term_func_t(struct perf_event_attr *attr,
struct parse_events_term *term,
struct parse_events_error *err);
static int config_term_common(struct perf_event_attr *attr,
struct parse_events_term *term, struct parse_events_term *term,
struct parse_events_error *err) struct parse_events_error *err)
{ {
...@@ -610,12 +614,6 @@ do { \ ...@@ -610,12 +614,6 @@ do { \
} while (0) } while (0)
switch (term->type_term) { switch (term->type_term) {
case PARSE_EVENTS__TERM_TYPE_USER:
/*
* Always succeed for sysfs terms, as we dont know
* at this point what type they need to have.
*/
return 0;
case PARSE_EVENTS__TERM_TYPE_CONFIG: case PARSE_EVENTS__TERM_TYPE_CONFIG:
CHECK_TYPE_VAL(NUM); CHECK_TYPE_VAL(NUM);
attr->config = term->val.num; attr->config = term->val.num;
...@@ -665,9 +663,24 @@ do { \ ...@@ -665,9 +663,24 @@ do { \
#undef CHECK_TYPE_VAL #undef CHECK_TYPE_VAL
} }
static int config_term_pmu(struct perf_event_attr *attr,
struct parse_events_term *term,
struct parse_events_error *err)
{
if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER)
/*
* Always succeed for sysfs terms, as we dont know
* at this point what type they need to have.
*/
return 0;
else
return config_term_common(attr, term, err);
}
static int config_attr(struct perf_event_attr *attr, static int config_attr(struct perf_event_attr *attr,
struct list_head *head, struct list_head *head,
struct parse_events_error *err) struct parse_events_error *err,
config_term_func_t config_term)
{ {
struct parse_events_term *term; struct parse_events_term *term;
...@@ -735,7 +748,8 @@ int parse_events_add_numeric(struct parse_events_evlist *data, ...@@ -735,7 +748,8 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
attr.config = config; attr.config = config;
if (head_config) { if (head_config) {
if (config_attr(&attr, head_config, data->error)) if (config_attr(&attr, head_config, data->error,
config_term_common))
return -EINVAL; return -EINVAL;
if (get_config_terms(head_config, &config_terms)) if (get_config_terms(head_config, &config_terms))
...@@ -795,7 +809,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data, ...@@ -795,7 +809,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
* Configure hardcoded terms first, no need to check * Configure hardcoded terms first, no need to check
* return value when called with fail == 0 ;) * return value when called with fail == 0 ;)
*/ */
if (config_attr(&attr, head_config, data->error)) if (config_attr(&attr, head_config, data->error, config_term_pmu))
return -EINVAL; return -EINVAL;
if (get_config_terms(head_config, &config_terms)) if (get_config_terms(head_config, &config_terms))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment