Skip to contentSkip to conversation

perf parse: Allow names to start with digits

PATCH Superseded Dominique Martinet 4 participants 11 messages Jun 12, 2022 – Oct 10, 2022 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf parse: Allow names to start with digits

Tracepoints can start with digits, although we don't have many of these:

$ rg -g '*.h' '\bTRACE_EVENT\([0-9]'
net/mac802154/trace.h
53:TRACE_EVENT(802154_drv_return_int,
...

net/ieee802154/trace.h
66:TRACE_EVENT(802154_rdev_add_virtual_intf,
...

include/trace/events/9p.h
124:TRACE_EVENT(9p_client_req,
...

Just allow names to start with digits too so e.g. perf probe -e '9p:*' works

---
 tools/perf/util/parse-events.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.l +1 -1
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source	[^,{}]+\.c[a-zA-Z0-9._]*
 num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
 name_tag	[\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
 drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
Signature · 1 line
2.36.1
#1 lore raw

Hello,

just making sure my mail didn't get lost -- would anyone have time to look at this?

I don't mind if it's slow or another solution is taken, I'd just like to be able to use 9p probes with perf eventually :)

Thanks!

Dominique Martinet wrote on Sun, Jun 12, 2022 at 03:15:08PM +0900:

Quoted 36 lines

Tracepoints can start with digits, although we don't have many of these:

$ rg -g '*.h' '\bTRACE_EVENT\([0-9]'
net/mac802154/trace.h
53:TRACE_EVENT(802154_drv_return_int,
...

net/ieee802154/trace.h
66:TRACE_EVENT(802154_rdev_add_virtual_intf,
...

include/trace/events/9p.h
124:TRACE_EVENT(9p_client_req,
...

Just allow names to start with digits too so e.g. perf probe -e '9p:*' works

---
 tools/perf/util/parse-events.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.l +1 -1
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source	[^,{}]+\.c[a-zA-Z0-9._]*
 num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
 name_tag	[\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
 drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
#2 lore raw

Em Sat, Jul 02, 2022 at 06:49:31PM +0900, Dominique Martinet escreveu:

Quoted 7 lines

Hello,

just making sure my mail didn't get lost -- would anyone have time to look at this?

I don't mind if it's slow or another solution is taken, I'd just like to be able to use 9p probes with perf eventually :)

Jiri, seems ok, can you please review?

Thanks,

- Arnaldo

Quoted 39 lines

Thanks!

Dominique Martinet wrote on Sun, Jun 12, 2022 at 03:15:08PM +0900:

Quoted 36 lines

Tracepoints can start with digits, although we don't have many of these:

$ rg -g '*.h' '\bTRACE_EVENT\([0-9]'
net/mac802154/trace.h
53:TRACE_EVENT(802154_drv_return_int,
...

net/ieee802154/trace.h
66:TRACE_EVENT(802154_rdev_add_virtual_intf,
...

include/trace/events/9p.h
124:TRACE_EVENT(9p_client_req,
...

Just allow names to start with digits too so e.g. perf probe -e '9p:*' works

---
 tools/perf/util/parse-events.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.l +1 -1
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source	[^,{}]+\.c[a-zA-Z0-9._]*
 num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
 name_tag	[\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
 drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
Signature · 1 line
- Arnaldo
#3 lore raw
Quoted 10 lines · Arnaldo Carvalho de Melo

Em Sat, Jul 02, 2022 at 06:49:31PM +0900, Dominique Martinet escreveu:

Quoted 7 lines

Hello,

just making sure my mail didn't get lost -- would anyone have time to look at this?

I don't mind if it's slow or another solution is taken, I'd just like to be able to use 9p probes with perf eventually :)

Jiri, seems ok, can you please review?

ah right, sorry, I remember looking on that before, but forgot to respond

Quoted 31 lines

Thanks,

- Arnaldo

Quoted 26 lines

Thanks!

Dominique Martinet wrote on Sun, Jun 12, 2022 at 03:15:08PM +0900:

Quoted 23 lines

Tracepoints can start with digits, although we don't have many of these:

$ rg -g '*.h' '\bTRACE_EVENT\([0-9]'
net/mac802154/trace.h
53:TRACE_EVENT(802154_drv_return_int,
...

net/ieee802154/trace.h
66:TRACE_EVENT(802154_rdev_add_virtual_intf,
...

include/trace/events/9p.h
124:TRACE_EVENT(9p_client_req,
...

Just allow names to start with digits too so e.g. perf probe -e '9p:*' works

---
 tools/perf/util/parse-events.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines
Quoted 10 lines

tools/perf/util/parse-events.l bpf_source [^,{}]+\.c[a-zA-Z0-9._]* · line 214

Quoted 10 lines
tools/perf/util/parse-events.l +1 -1
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source	[^,{}]+\.c[a-zA-Z0-9._]*
 num_dec		[0-9]+
 num_hex		0x[a-fA-F0-9]+
 num_raw_hex	[a-fA-F0-9]+
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

I thought it'd clash with events like cpu/event=3/, but lexer check numbers first, so we're fine there

it smells like it could break some events, but I couldn't find any case of that

could you please at least add tests to tests/parse-events.c for such case?

thanks,
jirka

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
tools/perf/util/parse-events.l +0 -0
 name_tag	[\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
 name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
 drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
Signature · 1 line
- Arnaldo
#4 lore raw

Jiri Olsa wrote on Sat, Jul 02, 2022 at 05:48:03PM +0200:

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

I thought it'd clash with events like cpu/event=3/, but lexer check numbers first, so we're fine there

it smells like it could break some events, but I couldn't find any case of that

could you please at least add tests to tests/parse-events.c for such case?

hmm, I'd love to but on my system I have no events that start with a number unless I manually modprobe 9pnet (or 802154 stuff), so tests would start failing for most people and I don't think we want that...

I have confirmed the following 'perf test "event parsing"' works iff patch is applied and 9pnet loaded:
----

tools/perf/tests/parse-events.c +5 -0
index 459afdb256a1..3d069fe9eb79 100644
@@ -1941,6 +1941,11 @@ static const struct evlist_test test__events[] = {
 		.check = test__exclusive_group,
 		/* 7 */
 	},
+	{
+		.name  = "9p:9p_client_req",
+		.check = test__checkevent_tracepoint,
+		/* 8 */
+	},
 };
 
 static const struct evlist_test test__events_pmu[] = {

----

not sure if there'd be any other way of testing, there's nothing else in 'perf list' that starts with a number.
--
Dominique

#5 lore raw
Quoted 38 lines · Dominique Martinet

Jiri Olsa wrote on Sat, Jul 02, 2022 at 05:48:03PM +0200:

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name		[a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

I thought it'd clash with events like cpu/event=3/, but lexer check numbers first, so we're fine there

it smells like it could break some events, but I couldn't find any case of that

could you please at least add tests to tests/parse-events.c for such case?

hmm, I'd love to but on my system I have no events that start with a number unless I manually modprobe 9pnet (or 802154 stuff), so tests would start failing for most people and I don't think we want that...

I have confirmed the following 'perf test "event parsing"' works iff patch is applied and 9pnet loaded:
----

tools/perf/tests/parse-events.c +5 -1
index 459afdb256a1..3d069fe9eb79 100644
@@ -1941,6 +1941,11 @@ static const struct evlist_test test__events[] = {
 		.check = test__exclusive_group,
 		/* 7 */
 	},
+	{
+		.name  = "9p:9p_client_req",
+		.check = test__checkevent_tracepoint,
+		/* 8 */
+	},
 };
 
 static const struct evlist_test test__events_pmu[] = {
----
Quoted 2 lines

not sure if there'd be any other way of testing, there's nothing else in 'perf list' that starts with a number.

maybe we could do it same way we did for fake pmu events like below

jirka

---

tools/perf/tests/parse-events.c +2 -2
index 3d069fe9eb79..0dc1fbc80447 100644
@@ -2058,7 +2058,7 @@ static int test_event(const struct evlist_test *e)
 		return TEST_FAIL;
 	}
 	parse_events_error__init(&err);
-	ret = parse_events(evlist, e->name, &err);
+	ret = __parse_events(evlist, e->name, &err, NULL, true);
 	if (ret) {
 		pr_debug("failed to parse event '%s', err %d, str '%s'\n",
 			 e->name, ret, err.str);
@@ -2087,7 +2087,7 @@ static int test_event_fake_pmu(const char *str)
 
 	parse_events_error__init(&err);
 	perf_pmu__test_parse_init();
-	ret = __parse_events(evlist, str, &err, &perf_pmu__fake);
+	ret = __parse_events(evlist, str, &err, &perf_pmu__fake, false);
 	if (ret) {
 		pr_debug("failed to parse event '%s', err %d, str '%s'\n",
 			 str, ret, err.str);
tools/perf/tests/pmu-events.c +1 -1
index f13368569d8b..27541d4d6025 100644
@@ -812,7 +812,7 @@ static int check_parse_id(const char *id, struct parse_events_error *error,
 	for (cur = strchr(dup, '@') ; cur; cur = strchr(++cur, '@'))
 		*cur = '/';
 
-	ret = __parse_events(evlist, dup, error, fake_pmu);
+	ret = __parse_events(evlist, dup, error, fake_pmu, false);
 	free(dup);
 
 	evlist__delete(evlist);
tools/perf/util/evsel.c +10 -6
index ce499c5da8d7..73771e22cb39 100644
@@ -476,7 +476,7 @@ struct evsel *evsel__clone(struct evsel *orig)
 /*
  * Returns pointer with encoded error via <linux/err.h> interface.
  */
-struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx)
+struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx, bool format)
 {
 	struct evsel *evsel = zalloc(perf_evsel__object.size);
 	int err = -ENOMEM;
@@ -493,14 +493,18 @@ struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx)
 		if (asprintf(&evsel->name, "%s:%s", sys, name) < 0)
 			goto out_free;
 
-		evsel->tp_format = trace_event__tp_format(sys, name);
-		if (IS_ERR(evsel->tp_format)) {
-			err = PTR_ERR(evsel->tp_format);
-			goto out_free;
+		if (format) {
+			evsel->tp_format = trace_event__tp_format(sys, name);
+			if (IS_ERR(evsel->tp_format)) {
+				err = PTR_ERR(evsel->tp_format);
+				goto out_free;
+			}
+			attr.config = evsel->tp_format->id;
+		} else {
+			attr.config = (__u64) -1;
 		}
 
 		event_attr_init(&attr);
-		attr.config = evsel->tp_format->id;
 		attr.sample_period = 1;
 		evsel__init(evsel, &attr, idx);
 	}
tools/perf/util/evsel.h +2 -2
index 73ea48e94079..255919658b57 100644
@@ -224,7 +224,7 @@ static inline struct evsel *evsel__new(struct perf_event_attr *attr)
 }
 
 struct evsel *evsel__clone(struct evsel *orig);
-struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx);
+struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx, bool format);
 
 int copy_config_terms(struct list_head *dst, struct list_head *src);
 void free_config_terms(struct list_head *config_terms);
@@ -234,7 +234,7 @@ void free_config_terms(struct list_head *config_terms);
  */
 static inline struct evsel *evsel__newtp(const char *sys, const char *name)
 {
-	return evsel__newtp_idx(sys, name, 0);
+	return evsel__newtp_idx(sys, name, 0, true);
 }
 
 struct evsel *evsel__new_cycles(bool precise, __u32 type, __u64 config);
tools/perf/util/metricgroup.c +1 -1
index 8f7baeabc5cf..8b066a0058f3 100644
@@ -1417,7 +1417,7 @@ static int parse_ids(bool metric_no_merge, struct perf_pmu *fake_pmu,
 	}
 	pr_debug("Parsing metric events '%s'\n", events.buf);
 	parse_events_error__init(&parse_error);
-	ret = __parse_events(parsed_evlist, events.buf, &parse_error, fake_pmu);
+	ret = __parse_events(parsed_evlist, events.buf, &parse_error, fake_pmu, false);
 	if (ret) {
 		parse_events_error__print(&parse_error, events.buf);
 		goto err_out;
tools/perf/util/parse-events.c +22 -14
index 7ed235740431..914d87fbad5b 100644
@@ -576,12 +576,14 @@ static void tracepoint_error(struct parse_events_error *e, int err,
 	parse_events_error__handle(e, 0, strdup(str), strdup(help));
 }
 
-static int add_tracepoint(struct list_head *list, int *idx,
+static int add_tracepoint(struct parse_events_state *parse_state,
+			  struct list_head *list,
 			  const char *sys_name, const char *evt_name,
 			  struct parse_events_error *err,
 			  struct list_head *head_config)
 {
-	struct evsel *evsel = evsel__newtp_idx(sys_name, evt_name, (*idx)++);
+	struct evsel *evsel = evsel__newtp_idx(sys_name, evt_name, parse_state->idx++,
+					       !parse_state->fake_tp);
 
 	if (IS_ERR(evsel)) {
 		tracepoint_error(err, PTR_ERR(evsel), sys_name, evt_name);
@@ -600,7 +602,8 @@ static int add_tracepoint(struct list_head *list, int *idx,
 	return 0;
 }
 
-static int add_tracepoint_multi_event(struct list_head *list, int *idx,
+static int add_tracepoint_multi_event(struct parse_events_state *parse_state,
+				      struct list_head *list,
 				      const char *sys_name, const char *evt_name,
 				      struct parse_events_error *err,
 				      struct list_head *head_config)
@@ -634,7 +637,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
 
 		found++;
 
-		ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name,
+		ret = add_tracepoint(parse_state, list, sys_name, evt_ent->d_name,
 				     err, head_config);
 	}
 
@@ -648,19 +651,21 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
 	return ret;
 }
 
-static int add_tracepoint_event(struct list_head *list, int *idx,
+static int add_tracepoint_event(struct parse_events_state *parse_state,
+				struct list_head *list,
 				const char *sys_name, const char *evt_name,
 				struct parse_events_error *err,
 				struct list_head *head_config)
 {
 	return strpbrk(evt_name, "*?") ?
-	       add_tracepoint_multi_event(list, idx, sys_name, evt_name,
+	       add_tracepoint_multi_event(parse_state, list, sys_name, evt_name,
 					  err, head_config) :
-	       add_tracepoint(list, idx, sys_name, evt_name,
+	       add_tracepoint(parse_state, list, sys_name, evt_name,
 			      err, head_config);
 }
 
-static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
+static int add_tracepoint_multi_sys(struct parse_events_state *parse_state,
+				    struct list_head *list,
 				    const char *sys_name, const char *evt_name,
 				    struct parse_events_error *err,
 				    struct list_head *head_config)
@@ -686,7 +691,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
 		if (!strglobmatch(events_ent->d_name, sys_name))
 			continue;
 
-		ret = add_tracepoint_event(list, idx, events_ent->d_name,
+		ret = add_tracepoint_event(parse_state, list, events_ent->d_name,
 					   evt_name, err, head_config);
 	}
 
@@ -723,7 +728,7 @@ static int add_bpf_event(const char *group, const char *event, int fd, struct bp
 	pr_debug("add bpf event %s:%s and attach bpf program %d\n",
 		 group, event, fd);
 
-	err = parse_events_add_tracepoint(&new_evsels, &parse_state->idx, group,
+	err = parse_events_add_tracepoint(parse_state, &new_evsels, group,
 					  event, parse_state->error,
 					  param->head_config);
 	if (err) {
@@ -1420,7 +1425,8 @@ static int get_config_chgs(struct perf_pmu *pmu, struct list_head *head_config,
 	return 0;
 }
 
-int parse_events_add_tracepoint(struct list_head *list, int *idx,
+int parse_events_add_tracepoint(struct parse_events_state *parse_state,
+				struct list_head *list,
 				const char *sys, const char *event,
 				struct parse_events_error *err,
 				struct list_head *head_config)
@@ -1434,10 +1440,10 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 	}
 
 	if (strpbrk(sys, "*?"))
-		return add_tracepoint_multi_sys(list, idx, sys, event,
+		return add_tracepoint_multi_sys(parse_state, list, sys, event,
 						err, head_config);
 	else
-		return add_tracepoint_event(list, idx, sys, event,
+		return add_tracepoint_event(parse_state, list, sys, event,
 					    err, head_config);
 }
 
@@ -2332,7 +2338,8 @@ static int parse_events__with_hybrid_pmu(struct parse_events_state *parse_state,
 }
 
 int __parse_events(struct evlist *evlist, const char *str,
-		   struct parse_events_error *err, struct perf_pmu *fake_pmu)
+		   struct parse_events_error *err,
+		   struct perf_pmu *fake_pmu, bool fake_tp)
 {
 	struct parse_events_state parse_state = {
 		.list	  = LIST_HEAD_INIT(parse_state.list),
@@ -2341,6 +2348,7 @@ int __parse_events(struct evlist *evlist, const char *str,
 		.evlist	  = evlist,
 		.stoken	  = PE_START_EVENTS,
 		.fake_pmu = fake_pmu,
+		.fake_tp  = fake_tp,
 	};
 	int ret;
 
tools/perf/util/parse-events.h +5 -3
index a38b8b160e80..bd2fb9a354b4 100644
@@ -34,12 +34,12 @@ const char *event_type(int type);
 int parse_events_option(const struct option *opt, const char *str, int unset);
 int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset);
 int __parse_events(struct evlist *evlist, const char *str, struct parse_events_error *error,
-		   struct perf_pmu *fake_pmu);
+		   struct perf_pmu *fake_pmu, bool fake_tp);
 
 static inline int parse_events(struct evlist *evlist, const char *str,
 			       struct parse_events_error *err)
 {
-	return __parse_events(evlist, str, err, NULL);
+	return __parse_events(evlist, str, err, NULL, false);
 }
 
 int parse_events_terms(struct list_head *terms, const char *str);
@@ -140,6 +140,7 @@ struct parse_events_state {
 	struct list_head	  *terms;
 	int			   stoken;
 	struct perf_pmu		  *fake_pmu;
+	bool			   fake_tp;
 	char			  *hybrid_pmu_name;
 };
 
@@ -163,7 +164,8 @@ void parse_events__clear_array(struct parse_events_array *a);
 int parse_events__modifier_event(struct list_head *list, char *str, bool add);
 int parse_events__modifier_group(struct list_head *list, char *event_mod);
 int parse_events_name(struct list_head *list, const char *name);
-int parse_events_add_tracepoint(struct list_head *list, int *idx,
+int parse_events_add_tracepoint(struct parse_events_state *parse_state,
+				struct list_head *list,
 				const char *sys, const char *event,
 				struct parse_events_error *error,
 				struct list_head *head_config);
tools/perf/util/parse-events.y +1 -1
index be8c51770051..83ccbf433482 100644
@@ -625,7 +625,7 @@ tracepoint_name opt_event_config
 	if (error)
 		error->idx = @1.first_column;
 
-	err = parse_events_add_tracepoint(list, &parse_state->idx, $1.sys, $1.event,
+	err = parse_events_add_tracepoint(parse_state, list, $1.sys, $1.event,
 					error, $2);
 
 	parse_events_terms__delete($2);
#6 lore raw

Jiri Olsa wrote on Sun, Jul 03, 2022 at 03:46:33PM +0200:

Quoted 4 lines
Quoted 2 lines

not sure if there'd be any other way of testing, there's nothing else in 'perf list' that starts with a number.

maybe we could do it same way we did for fake pmu events like below

hmm, I'll have to defer to you on that honestly.

It looks good to me though and I've tested your diff (test succeeds even with 9pnet module unloaded).

Just a note though, this makes test no longer checks the sys event directories exist for all other tests in these arrays (test__events, test__events_pmu and test__hybrid_events); if we have guarantees the probes exist I believe at least a few should keep checking the format path correctly.
It might be worth adding a check_format flag to test_event() and add a new list that doesn't check formats just for 9p?

If you're ok with that I can resend this as three patches: my original patch, a patch with your diff and test_event() keeping current behaviour, and a last patch adding that last flag and testing 9p without format check.

(and if you don't think it's worth checking probe existence same thing but even simpler)
--
Dominique

#7 lore raw
Quoted 11 lines · Dominique Martinet

Jiri Olsa wrote on Sun, Jul 03, 2022 at 03:46:33PM +0200:

Quoted 4 lines
Quoted 2 lines

not sure if there'd be any other way of testing, there's nothing else in 'perf list' that starts with a number.

maybe we could do it same way we did for fake pmu events like below

hmm, I'll have to defer to you on that honestly.

It looks good to me though and I've tested your diff (test succeeds even with 9pnet module unloaded).

Quoted 7 lines

Just a note though, this makes test no longer checks the sys event directories exist for all other tests in these arrays (test__events, test__events_pmu and test__hybrid_events); if we have guarantees the probes exist I believe at least a few should keep checking the format path correctly.
It might be worth adding a check_format flag to test_event() and add a new list that doesn't check formats just for 9p?

format provides only id which we don't check for tracepoints

Quoted 8 lines

If you're ok with that I can resend this as three patches: my original patch, a patch with your diff and test_event() keeping current behaviour, and a last patch adding that last flag and testing 9p without format check.

(and if you don't think it's worth checking probe existence same thing but even simpler)

I have that patch split into 2 separated changes,
I'll try to send it later today

jirka

reviewer
#8 lore raw
In reply to Dominique Martinet
Quoted 29 lines · Dominique Martinet

Tracepoints can start with digits, although we don't have many of these:

$ rg -g '*.h' '\bTRACE_EVENT\([0-9]'
net/mac802154/trace.h
53:TRACE_EVENT(802154_drv_return_int,
...

net/ieee802154/trace.h
66:TRACE_EVENT(802154_rdev_add_virtual_intf,
...

include/trace/events/9p.h
124:TRACE_EVENT(9p_client_req,
...

Just allow names to start with digits too so e.g. perf probe -e '9p:*' works

---
 tools/perf/util/parse-events.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/parse-events.l +0 -0
index 5b6e4b5249cf..4133d6950d29 100644

tools/perf/util/parse-events.l bpf_source [^,{}]+\.c[a-zA-Z0-9._]* · line 214

Quoted 5 lines
tools/perf/util/parse-events.l +1 -1
@@ -211,7 +211,7 @@ bpf_source  [^,{}]+\.c[a-zA-Z0-9._]*
 num_dec                [0-9]+
 num_hex                0x[a-fA-F0-9]+
 num_raw_hex    [a-fA-F0-9]+
-name           [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name           [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

Perhaps this would be cleaner as:
name [a-zA-Z0-9_*?\[\]!]+
except that would allow a name to start with an exclamation. Would that be an issue?

Thanks,
Ian

Quoted 6 lines
tools/perf/util/parse-events.l +0 -1
 name_tag       [\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
 name_minus     [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
 drv_cfg_term   [a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
--

2.36.1

#9 lore raw

Hi Jiri, Ian,

Jiri Olsa wrote on Mon, Jul 04, 2022 at 01:25:28PM +0200:

Quoted 10 lines
Quoted 7 lines

If you're ok with that I can resend this as three patches: my original patch, a patch with your diff and test_event() keeping current behaviour, and a last patch adding that last flag and testing 9p without format check.

(and if you don't think it's worth checking probe existence same thing but even simpler)

I have that patch split into 2 separated changes,
I'll try to send it later today

It's been a while (I had totally forgotten), but I don't think I saw this patch.

For reminder you've requested that I add some test for a tracepoint starting with digits e.g. 9p:9p_client_res but there's nothing commonly available to use there, so you added a way to only check without checking if a backing tracepoint exist, but I see no trace of the update you sent here:
https://lore.kernel.org/all/YsGduWiTvkM2/tHv@krava/

Should I take it, do the split you suggested and send it together with a resend of my original patch and new test?

Ian Rogers wrote on Mon, Jul 04, 2022 at 02:39:05PM -0700:

Quoted 7 lines
Quoted 7 lines
tools/perf/util/parse-events.l +0 -0
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source  [^,{}]+\.c[a-zA-Z0-9._]*
 num_dec                [0-9]+
 num_hex                0x[a-fA-F0-9]+
Quoted 8 lines

tools/perf/util/parse-events.l bpf_source [^,{}]+\.c[a-zA-Z0-9._]* · line 214

Quoted 3 lines
tools/perf/util/parse-events.l +1 -1
 num_raw_hex    [a-fA-F0-9]+
-name           [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name           [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

Perhaps this would be cleaner as:
name [a-zA-Z0-9_*?\[\]!]+
except that would allow a name to start with an exclamation. Would that be an issue?

Sorry for the lack of reply -- I have no opinion on this as long as we can use digits.
I can't imagine any probe starting with . or !, but that does not seem to create any ambiguity with the rest of the grammar that I can see either so I think it'd be fine, but I'm not comfortable deciding.

Thanks,
--
Dominique

#10 lore raw
Quoted 24 lines · Dominique Martinet

Hi Jiri, Ian,

Jiri Olsa wrote on Mon, Jul 04, 2022 at 01:25:28PM +0200:

Quoted 10 lines
Quoted 7 lines

If you're ok with that I can resend this as three patches: my original patch, a patch with your diff and test_event() keeping current behaviour, and a last patch adding that last flag and testing 9p without format check.

(and if you don't think it's worth checking probe existence same thing but even simpler)

I have that patch split into 2 separated changes,
I'll try to send it later today

It's been a while (I had totally forgotten), but I don't think I saw this patch.

For reminder you've requested that I add some test for a tracepoint starting with digits e.g. 9p:9p_client_res but there's nothing commonly available to use there, so you added a way to only check without checking if a backing tracepoint exist, but I see no trace of the update you sent here:
https://lore.kernel.org/all/YsGduWiTvkM2/tHv@krava/

Quoted 2 lines

Should I take it, do the split you suggested and send it together with a resend of my original patch and new test?

ah, it fell through the cracks, sry.. if you could resend it, that'd be great

thanks,
jirka

Quoted 29 lines

Ian Rogers wrote on Mon, Jul 04, 2022 at 02:39:05PM -0700:

Quoted 7 lines
Quoted 7 lines
tools/perf/util/parse-events.l +0 -0
index 5b6e4b5249cf..4133d6950d29 100644
@@ -211,7 +211,7 @@ bpf_source  [^,{}]+\.c[a-zA-Z0-9._]*
 num_dec                [0-9]+
 num_hex                0x[a-fA-F0-9]+
Quoted 8 lines

tools/perf/util/parse-events.l bpf_source [^,{}]+\.c[a-zA-Z0-9._]* · line 214

Quoted 3 lines
tools/perf/util/parse-events.l +1 -1
 num_raw_hex    [a-fA-F0-9]+
-name           [a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]!]*
+name           [a-zA-Z0-9_*?\[\]][a-zA-Z0-9_*?.\[\]!]*

Perhaps this would be cleaner as:
name [a-zA-Z0-9_*?\[\]!]+
except that would allow a name to start with an exclamation. Would that be an issue?

Sorry for the lack of reply -- I have no opinion on this as long as we can use digits.
I can't imagine any probe starting with . or !, but that does not seem to create any ambiguity with the rest of the grammar that I can see either so I think it'd be fine, but I'm not comfortable deciding.

Thanks,
--
Dominique