perf probe: Add --cache option to cache the probe definitions
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Wed, 15 Jun 2016 03:28:40 +0000 (12:28 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 15 Jun 2016 17:34:42 +0000 (14:34 -0300)
Add --cache option to cache the probe definitions. This just saves the
result of the dwarf analysis to probe cache.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160615032840.31330.44412.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-probe.txt
tools/perf/builtin-probe.c
tools/perf/util/probe-event.c
tools/perf/util/probe-event.h

index 3a8a9ba2b0412aba28f1796e283106f84ec63266..947db6fe512c81990b4bfa519f885f76af55d554 100644 (file)
@@ -109,6 +109,10 @@ OPTIONS
        Dry run. With this option, --add and --del doesn't execute actual
        adding and removal operations.
 
+--cache::
+       Cache the probes (with --add option). Any events which successfully added
+       are also stored in the cache file.
+
 --max-probes=NUM::
        Set the maximum number of probe points for an event. Default is 128.
 
index 9af859b28b15cc74edbf8041278ec2ee9e47104e..6d7ab43164495714f129b40c24d02b019bd22106 100644 (file)
@@ -512,6 +512,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
                    "Enable symbol demangling"),
        OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
                    "Enable kernel symbol demangling"),
+       OPT_BOOLEAN(0, "cache", &probe_conf.cache, "Manipulate probe cache"),
        OPT_END()
        };
        int ret;
index cbc8a8bf0f362812d9e906773fc7c8d4b2a7a297..084756c173094c53e393b5f999968f9ade2a13a2 100644 (file)
@@ -2514,6 +2514,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 {
        int i, fd, ret;
        struct probe_trace_event *tev = NULL;
+       struct probe_cache *cache = NULL;
        struct strlist *namelist;
 
        fd = probe_file__open(PF_FL_RW | (pev->uprobes ? PF_FL_UPROBE : 0));
@@ -2555,6 +2556,14 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
        }
        if (ret == -EINVAL && pev->uprobes)
                warn_uprobe_event_compat(tev);
+       if (ret == 0 && probe_conf.cache) {
+               cache = probe_cache__new(pev->target);
+               if (!cache ||
+                   probe_cache__add_entry(cache, pev, tevs, ntevs) < 0 ||
+                   probe_cache__commit(cache) < 0)
+                       pr_warning("Failed to add event to probe cache\n");
+               probe_cache__delete(cache);
+       }
 
        strlist__delete(namelist);
 close_out:
index 0b024ba789e30fdd9dddbb8fe16a6124d40a3552..432b690d3f177ae73de222b390e472218ea296be 100644 (file)
@@ -12,6 +12,7 @@ struct probe_conf {
        bool    show_location_range;
        bool    force_add;
        bool    no_inlines;
+       bool    cache;
        int     max_probes;
 };
 extern struct probe_conf probe_conf;