The init/exit_probe_symbol_maps() was a part of
convert_perf_probe_events() and cleanup_perf_probe_events().  But as
these functions can be called multiple times, it'd be better moving
init/exit functions out of them, so that it should be called only once.

Cc: Masami Hiramatsu <[email protected]>
Cc: Wang Nan <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
 tools/perf/builtin-probe.c    |  5 +++++
 tools/perf/util/probe-event.c | 11 +++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 2bec9c1ef2a3..94385ee89dc8 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -317,6 +317,10 @@ static int perf_add_probe_events(struct perf_probe_event 
*pevs, int npevs)
        int i, k;
        const char *event = NULL, *group = NULL;
 
+       ret = init_probe_symbol_maps(pevs->uprobes);
+       if (ret < 0)
+               return ret;
+
        ret = convert_perf_probe_events(pevs, npevs);
        if (ret < 0)
                goto out_cleanup;
@@ -354,6 +358,7 @@ static int perf_add_probe_events(struct perf_probe_event 
*pevs, int npevs)
 
 out_cleanup:
        cleanup_perf_probe_events(pevs, npevs);
+       exit_probe_symbol_maps();
        return ret;
 }
 
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 64e15cba7223..2b78e8f19b45 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2746,10 +2746,6 @@ int convert_perf_probe_events(struct perf_probe_event 
*pevs, int npevs)
 {
        int i, ret;
 
-       ret = init_probe_symbol_maps(pevs->uprobes);
-       if (ret < 0)
-               return ret;
-
        /* Loop 1: convert all events */
        for (i = 0; i < npevs; i++) {
                /* Init kprobe blacklist if needed */
@@ -2794,20 +2790,23 @@ void cleanup_perf_probe_events(struct perf_probe_event 
*pevs, int npevs)
                pevs[i].ntevs = 0;
                clear_perf_probe_event(&pevs[i]);
        }
-
-       exit_probe_symbol_maps();
 }
 
 int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
 {
        int ret;
 
+       ret = init_probe_symbol_maps(pevs->uprobes);
+       if (ret < 0)
+               return ret;
+
        ret = convert_perf_probe_events(pevs, npevs);
        if (ret == 0)
                ret = apply_perf_probe_events(pevs, npevs);
 
        cleanup_perf_probe_events(pevs, npevs);
 
+       exit_probe_symbol_maps();
        return ret;
 }
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to