Skip to contentSkip to conversation

perf probe: Fix to delete multiple probe event

PATCH Superseded Masami Hiramatsu 2 participants 4 messages Dec 3, 2019 – Jan 8, 2020 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf probe: Fix to delete multiple probe event

Fix to delete multiple probe event with filter correctly.

When we put an event with multiple probes, perf-probe fails to delete with filters. This comes from a failure to list up the event name because of overwrapping its name.

To fix this issue, skip to list up the event which has same name.

Without this patch:

  # perf probe -l \*
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:21@
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:25@
    probe_perf:map__map_ip (on append_inlines:12@util/machine.c in
    probe_perf:map__map_ip (on unwind_entry:19@util/machine.c in /
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
  # perf probe -d \*
  "*" does not hit any event.
    Error: Failed to delete events. Reason: No such file or directory (Code: -2)

With this:

  # perf probe -d \*
  Removed event: probe_perf:map__map_ip
---
 tools/perf/util/probe-file.c |    3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/probe-file.c +3 -0
index 5003ba403345..c03a591d41a4 100644
@@ -206,6 +206,9 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
 		} else
 			ret = strlist__add(sl, tev.event);
 		clear_probe_trace_event(&tev);
+		/* Skip if there is same name multi-probe event in the list */
+		if (ret == -EEXIST)
+			ret = 0;
 		if (ret < 0)
 			break;
 	}
#1 lore raw
Quoted 21 lines · On Tue, 3 Dec 2019 17:01:54 +0900 Masami Hiramatsu <[email protected]> wrote:

Fix to delete multiple probe event with filter correctly.

When we put an event with multiple probes, perf-probe fails to delete with filters. This comes from a failure to list up the event name because of overwrapping its name.

To fix this issue, skip to list up the event which has same name.

Without this patch:

  # perf probe -l \*
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:21@
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:25@
    probe_perf:map__map_ip (on append_inlines:12@util/machine.c in
    probe_perf:map__map_ip (on unwind_entry:19@util/machine.c in /
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
  # perf probe -d \*
  "*" does not hit any event.
    Error: Failed to delete events. Reason: No such file or directory (Code: -2)
Quoted 4 lines

With this:

  # perf probe -d \*
  Removed event: probe_perf:map__map_ip

Oops, I missed Fixed tag.

Fixes 72363540c009 ("perf probe: Support multiprobe event")

Thanks,

Quoted 21 lines
---
 tools/perf/util/probe-file.c |    3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/probe-file.c +3 -0
index 5003ba403345..c03a591d41a4 100644
@@ -206,6 +206,9 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
 		} else
 			ret = strlist__add(sl, tev.event);
 		clear_probe_trace_event(&tev);
+		/* Skip if there is same name multi-probe event in the list */
+		if (ret == -EEXIST)
+			ret = 0;
 		if (ret < 0)
 			break;
 	}
Signature · 1 line
Masami Hiramatsu <[email protected]>
#2 lore raw

Hi Arnaldo,

Could you pick this fix?

Sandipan, could you also test this?

Thank you,

Quoted 60 lines · On Wed, 4 Dec 2019 11:29:52 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 21 lines · On Tue, 3 Dec 2019 17:01:54 +0900 Masami Hiramatsu <[email protected]> wrote:

Fix to delete multiple probe event with filter correctly.

When we put an event with multiple probes, perf-probe fails to delete with filters. This comes from a failure to list up the event name because of overwrapping its name.

To fix this issue, skip to list up the event which has same name.

Without this patch:

  # perf probe -l \*
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:21@
    probe_perf:map__map_ip (on perf_sample__fprintf_brstackoff:25@
    probe_perf:map__map_ip (on append_inlines:12@util/machine.c in
    probe_perf:map__map_ip (on unwind_entry:19@util/machine.c in /
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
    probe_perf:map__map_ip (on map__map_ip@util/map.h in /home/mhi
  # perf probe -d \*
  "*" does not hit any event.
    Error: Failed to delete events. Reason: No such file or directory (Code: -2)
Quoted 4 lines

With this:

  # perf probe -d \*
  Removed event: probe_perf:map__map_ip

Oops, I missed Fixed tag.

Fixes 72363540c009 ("perf probe: Support multiprobe event")

Thanks,

Quoted 21 lines
---
 tools/perf/util/probe-file.c |    3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/probe-file.c +3 -0
index 5003ba403345..c03a591d41a4 100644
@@ -206,6 +206,9 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
 		} else
 			ret = strlist__add(sl, tev.event);
 		clear_probe_trace_event(&tev);
+		/* Skip if there is same name multi-probe event in the list */
+		if (ret == -EEXIST)
+			ret = 0;
 		if (ret < 0)
 			break;
 	}
Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
Masami Hiramatsu <[email protected]>