diff options
author | Ingo Molnar <mingo@kernel.org> | 2012-05-21 09:17:31 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-05-21 09:17:50 +0200 |
commit | bb27f55eb9405257a59c82550dbb0d684cc3a665 (patch) | |
tree | bdab5866709e6ac7eeef7493d7d73bbd3d6231b6 /tools/perf/util/parse-events.c | |
parent | b732d439cb43336cd6d7e804ecb2c81193ef63b0 (diff) | |
parent | 5e1c81d98a5621007824b49dde556fead5ff9c6c (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Fixes for perf/core:
- Rename some perf_target methods to avoid double negation, from Namhyung Kim.
- Revert change to use per task events with inheritance, from Namhyung Kim.
- Events should start disabled till children starts running, from David Ahern.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r-- | tools/perf/util/parse-events.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 5b3a0ef4e232..c7fc18a33d54 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -593,17 +593,27 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx, static int config_term(struct perf_event_attr *attr, struct parse_events__term *term) { - switch (term->type) { +#define CHECK_TYPE_VAL(type) \ +do { \ + if (PARSE_EVENTS__TERM_TYPE_ ## type != term->type_val) \ + return -EINVAL; \ +} while (0) + + switch (term->type_term) { case PARSE_EVENTS__TERM_TYPE_CONFIG: + CHECK_TYPE_VAL(NUM); attr->config = term->val.num; break; case PARSE_EVENTS__TERM_TYPE_CONFIG1: + CHECK_TYPE_VAL(NUM); attr->config1 = term->val.num; break; case PARSE_EVENTS__TERM_TYPE_CONFIG2: + CHECK_TYPE_VAL(NUM); attr->config2 = term->val.num; break; case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: + CHECK_TYPE_VAL(NUM); attr->sample_period = term->val.num; break; case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: @@ -615,7 +625,9 @@ static int config_term(struct perf_event_attr *attr, default: return -EINVAL; } + return 0; +#undef CHECK_TYPE_VAL } static int config_attr(struct perf_event_attr *attr, @@ -1015,11 +1027,12 @@ void print_events(const char *event_glob) int parse_events__is_hardcoded_term(struct parse_events__term *term) { - return term->type <= PARSE_EVENTS__TERM_TYPE_HARDCODED_MAX; + return term->type_term != PARSE_EVENTS__TERM_TYPE_USER; } -int parse_events__new_term(struct parse_events__term **_term, int type, - char *config, char *str, long num) +static int new_term(struct parse_events__term **_term, int type_val, + int type_term, char *config, + char *str, long num) { struct parse_events__term *term; @@ -1028,15 +1041,11 @@ int parse_events__new_term(struct parse_events__term **_term, int type, return -ENOMEM; INIT_LIST_HEAD(&term->list); - term->type = type; + term->type_val = type_val; + term->type_term = type_term; term->config = config; - switch (type) { - case PARSE_EVENTS__TERM_TYPE_CONFIG: - case PARSE_EVENTS__TERM_TYPE_CONFIG1: - case PARSE_EVENTS__TERM_TYPE_CONFIG2: - case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: - case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: + switch (type_val) { case PARSE_EVENTS__TERM_TYPE_NUM: term->val.num = num; break; @@ -1051,6 +1060,20 @@ int parse_events__new_term(struct parse_events__term **_term, int type, return 0; } +int parse_events__term_num(struct parse_events__term **term, + int type_term, char *config, long num) +{ + return new_term(term, PARSE_EVENTS__TERM_TYPE_NUM, type_term, + config, NULL, num); +} + +int parse_events__term_str(struct parse_events__term **term, + int type_term, char *config, char *str) +{ + return new_term(term, PARSE_EVENTS__TERM_TYPE_STR, type_term, + config, str, 0); +} + void parse_events__free_terms(struct list_head *terms) { struct parse_events__term *term, *h; |