All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/5] perf probe: Split add_perf_probe_events()
@ 2015-09-04 12:15 Namhyung Kim
  2015-09-04 12:16 ` [PATCH v2 2/5] perf probe: Attach trace_probe_event with perf_probe_event Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Namhyung Kim @ 2015-09-04 12:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Masami Hiramatsu,
	Wang Nan, pi3orama

The add_perf_probe_events() does 3 things:

 1. convert all perf events to trace events
 2. add all trace events to kernel
 3. cleanup all trace events

But sometimes we need to do something with the trace events.  So split
the funtion into three, so that it can access intermediate trace events
via struct __event_package if needed.

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/probe-event.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index eb5f18b75402..2c762f41e7a5 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2765,9 +2765,10 @@ struct __event_package {
 	int				ntevs;
 };
 
-int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
+static int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs,
+				     struct __event_package **ppkgs)
 {
-	int i, j, ret;
+	int i, ret;
 	struct __event_package *pkgs;
 
 	ret = 0;
@@ -2792,12 +2793,21 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
 		ret  = convert_to_probe_trace_events(pkgs[i].pev,
 						     &pkgs[i].tevs);
 		if (ret < 0)
-			goto end;
+			return ret;
 		pkgs[i].ntevs = ret;
 	}
 	/* This just release blacklist only if allocated */
 	kprobe_blacklist__release();
 
+	*ppkgs = pkgs;
+
+	return 0;
+}
+
+static int apply_perf_probe_events(struct __event_package *pkgs, int npevs)
+{
+	int i, ret = 0;
+
 	/* Loop 2: add all events */
 	for (i = 0; i < npevs; i++) {
 		ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
@@ -2806,7 +2816,16 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
 		if (ret < 0)
 			break;
 	}
-end:
+	return ret;
+}
+
+static void cleanup_perf_probe_events(struct __event_package *pkgs, int npevs)
+{
+	int i, j;
+
+	if (pkgs == NULL)
+		return;
+
 	/* Loop 3: cleanup and free trace events  */
 	for (i = 0; i < npevs; i++) {
 		for (j = 0; j < pkgs[i].ntevs; j++)
@@ -2815,6 +2834,18 @@ end:
 	}
 	free(pkgs);
 	exit_symbol_maps();
+}
+
+int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
+{
+	int ret;
+	struct __event_package *pkgs = NULL;
+
+	ret = convert_perf_probe_events(pevs, npevs, &pkgs);
+	if (ret == 0)
+		ret = apply_perf_probe_events(pkgs, npevs);
+
+	cleanup_perf_probe_events(pkgs, npevs);
 
 	return ret;
 }
-- 
2.5.0


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

end of thread, other threads:[~2015-09-11 16:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-04 12:15 [PATCH v2 1/5] perf probe: Split add_perf_probe_events() Namhyung Kim
2015-09-04 12:16 ` [PATCH v2 2/5] perf probe: Attach trace_probe_event with perf_probe_event Namhyung Kim
2015-09-08 14:39   ` [tip:perf/core] perf probe: Link trace_probe_event into perf_probe_event tip-bot for Wang Nan
2015-09-04 12:16 ` [PATCH v2 3/5] perf probe: Move print logic into cmd_probe() Namhyung Kim
2015-09-08 14:39   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-04 12:16 ` [PATCH v2 4/5] perf probe: Split del_perf_probe_events() Namhyung Kim
2015-09-08 14:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-04 12:16 ` [PATCH v2 5/5] perf probe: Print deleted events in cmd_probe() Namhyung Kim
2015-09-07  1:12   ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-08 14:40   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-06  7:47 ` [PATCH v2 1/5] perf probe: Split add_perf_probe_events() Wangnan (F)
2015-09-08  1:53   ` Namhyung Kim
2015-09-10  2:23   ` Namhyung Kim
2015-09-10  5:00     ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-10  6:40       ` Namhyung Kim
2015-09-10  8:10         ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-11 16:29           ` Namhyung Kim
2015-09-08 14:39 ` [tip:perf/core] " tip-bot for Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.