public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] perf tools: Adds the config_term callback for different type events
@ 2015-09-25 11:11 He Kuang
  2015-09-25 11:11 ` [PATCH v2 2/4] perf tools: Prompt error message for wrong terms of hw/sw events He Kuang
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: He Kuang @ 2015-09-25 11:11 UTC (permalink / raw)
  To: a.p.zijlstra, mingo, acme, jolsa, kan.liang, adrian.hunter
  Cc: wangnan0, pi3orama, hekuang, linux-kernel

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: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/parse-events.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 61c2bc2..aa64cf3 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -599,7 +599,11 @@ static int check_type_val(struct parse_events_term *term,
 	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_error *err)
 {
@@ -610,12 +614,6 @@ do {									   \
 } while (0)
 
 	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:
 		CHECK_TYPE_VAL(NUM);
 		attr->config = term->val.num;
@@ -665,9 +663,24 @@ do {									   \
 #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,
 		       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;
 
@@ -735,7 +748,8 @@ int parse_events_add_numeric(struct parse_events_evlist *data,
 	attr.config = 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;
 
 		if (get_config_terms(head_config, &config_terms))
@@ -795,7 +809,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
 	 * Configure hardcoded terms first, no need to check
 	 * 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;
 
 	if (get_config_terms(head_config, &config_terms))
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-09-27 20:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-25 11:11 [PATCH v2 1/4] perf tools: Adds the config_term callback for different type events He Kuang
2015-09-25 11:11 ` [PATCH v2 2/4] perf tools: Prompt error message for wrong terms of hw/sw events He Kuang
2015-09-27 20:27   ` Jiri Olsa
2015-09-27 20:28   ` Jiri Olsa
2015-09-27 20:30   ` Jiri Olsa
2015-09-25 11:11 ` [PATCH v2 3/4] perf tools: Adds the tracepoint name parsing support He Kuang
2015-09-27 20:33   ` Jiri Olsa
2015-09-27 20:34   ` Jiri Olsa
2015-09-25 11:11 ` [PATCH v2 4/4] perf tools: Enable event_config terms to tracepoint events He Kuang
2015-09-27 20:41   ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox