Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1560139
| From | Masami Hiramatsu <mhiramat@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH perf/core v2 4/4] perf-probe: Find probe events without target module |
| Date | 2017-01-16 23:30 +0100 |
| Message-ID | <t0nWN-6UL-19@gated-at.bofh.it> (permalink) |
| References | <sYk6Z-2RD-1@gated-at.bofh.it> <sYkgF-3b0-15@gated-at.bofh.it> <t0kvT-4pV-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, 16 Jan 2017 15:44:55 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Em Wed, Jan 11, 2017 at 03:03:06PM +0900, Masami Hiramatsu escreveu:
> > Find probe events without -m "module" option. If perf-probe
> > failed to find given function in kernel image, it tries to
> > find same symbol and module in kallsyms, and retry search
> > in the found module. E.g.
> >
> > # perf probe -D i915_capabilities
> > p:probe/i915_capabilities i915:i915_capabilities+0
> >
> > Note: without -m option, perf probe can not find inlined
> > function since there is no symbol information in kallsyms.
>
> As this is a new feature, I'll postpone merging it till we get
> perf/urgent, with the first three patches in this series, merged into
> perf/core, ok?
Agreed :-)
Thank you!
>
> - Arnaldo
>
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> > Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > ---
> > Changes in v2:
> > - Fix to remove unneeded zero-return.
> > - Remove unneeded debug message.
> > ---
> > tools/perf/util/probe-event.c | 69 ++++++++++++++++++++++++++++++-----------
> > 1 file changed, 51 insertions(+), 18 deletions(-)
> >
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 6a6f44d..715f330 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -858,11 +858,7 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
> >
> > debuginfo__delete(dinfo);
> >
> > - if (ntevs == 0) { /* No error but failed to find probe point. */
> > - pr_warning("Probe point '%s' not found.\n",
> > - synthesize_perf_probe_point(&pev->point));
> > - return -ENOENT;
> > - } else if (ntevs < 0) {
> > + if (ntevs < 0) {
> > /* Error path : ntevs < 0 */
> > pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
> > if (ntevs == -EBADF)
> > @@ -2829,9 +2825,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
> > */
> > num_matched_functions = find_probe_functions(map, pp->function, syms);
> > if (num_matched_functions == 0) {
> > - pr_err("Failed to find symbol %s in %s\n", pp->function,
> > - pev->target ? : "kernel");
> > - ret = -ENOENT;
> > + ret = 0;
> > goto out;
> > } else if (num_matched_functions > probe_conf.max_probes) {
> > pr_err("Too many functions matched in %s\n",
> > @@ -3233,6 +3227,42 @@ static int find_probe_trace_events_from_cache(struct perf_probe_event *pev,
> > return ret;
> > }
> >
> > +static int __convert_to_probe_trace_events(struct perf_probe_event *pev,
> > + struct probe_trace_event **tevs)
> > +{
> > + int ret;
> > +
> > + /* At first, we need to lookup cache entry */
> > + ret = find_probe_trace_events_from_cache(pev, tevs);
> > + if (ret > 0 || pev->sdt) /* SDT can be found only in the cache */
> > + return ret == 0 ? -ENOENT : ret; /* Found in probe cache */
> > +
> > + /* Convert perf_probe_event with debuginfo */
> > + ret = try_to_find_probe_trace_events(pev, tevs);
> > + if (ret != 0)
> > + return ret; /* Found in debuginfo or got an error */
> > +
> > + return find_probe_trace_events_from_map(pev, tevs);
> > +}
> > +
> > +static char *find_module_from_kallsyms(const char *symbol_name)
> > +{
> > + struct machine *machine = machine__new_kallsyms();
> > + struct symbol *sym;
> > + struct map *map;
> > + char *module;
> > +
> > + sym = machine__find_kernel_function_by_name(machine, symbol_name, &map);
> > + if (!sym || map->dso->short_name[0] != '[')
> > + return NULL;
> > + pr_debug("Found %s in %s\n", sym->name, map->dso->short_name);
> > + module = strdup(map->dso->short_name + 1);
> > + if (module)
> > + module[strlen(module) - 1] = '\0';
> > +
> > + return module;
> > +}
> > +
> > static int convert_to_probe_trace_events(struct perf_probe_event *pev,
> > struct probe_trace_event **tevs)
> > {
> > @@ -3255,17 +3285,20 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev,
> > if (ret > 0)
> > return ret;
> >
> > - /* At first, we need to lookup cache entry */
> > - ret = find_probe_trace_events_from_cache(pev, tevs);
> > - if (ret > 0 || pev->sdt) /* SDT can be found only in the cache */
> > - return ret == 0 ? -ENOENT : ret; /* Found in probe cache */
> > -
> > - /* Convert perf_probe_event with debuginfo */
> > - ret = try_to_find_probe_trace_events(pev, tevs);
> > - if (ret != 0)
> > - return ret; /* Found in debuginfo or got an error */
> > + ret = __convert_to_probe_trace_events(pev, tevs);
> > + /* Not found. will retry to check kmodule if possible */
> > + if (ret == 0 && !pev->uprobes && !pev->target) {
> > + pev->target = find_module_from_kallsyms(pev->point.function);
> > + if (pev->target)
> > + ret = __convert_to_probe_trace_events(pev, tevs);
> > + }
> >
> > - return find_probe_trace_events_from_map(pev, tevs);
> > + if (ret == 0) {
> > + pr_warning("Probe point '%s' not found.\n",
> > + synthesize_perf_probe_point(&pev->point));
> > + ret = -ENOENT;
> > + }
> > + return ret;
> > }
> >
> > int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs)
--
Masami Hiramatsu <mhiramat@kernel.org>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH perf/core v2 0/4] perf-probe: Fix and improve module probe events Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 07:00 +0100
[PATCH perf/core v2 3/4] perf-probe: Fix to probe on gcc generated functions in modules Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 07:10 +0100
[tip:perf/urgent] perf probe: Fix to probe on gcc generated functions in modules tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2017-01-18 10:30 +0100
[PATCH perf/core v2 1/4] perf-probe: Fix to show correct locations for events on modules Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 07:10 +0100
Re: [PATCH perf/core v2 1/4] perf-probe: Fix to show correct locations for events on modules Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-16 19:40 +0100
[tip:perf/urgent] perf probe: Fix to show correct locations for events on modules tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2017-01-18 11:00 +0100
[PATCH perf/core v2 4/4] perf-probe: Find probe events without target module Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 07:10 +0100
Re: [PATCH perf/core v2 4/4] perf-probe: Find probe events without target module Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-16 19:50 +0100
Re: [PATCH perf/core v2 4/4] perf-probe: Find probe events without target module Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-16 23:30 +0100
[PATCH perf/core v2 2/4] perf-probe: Add error checks to offline probe post-processing Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-11 07:10 +0100
[tip:perf/urgent] perf probe: Add error checks to offline probe post-processing tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2017-01-18 10:30 +0100
Re: [PATCH perf/core v2 0/4] perf-probe: Fix and improve module probe events Masami Hiramatsu <mhiramat@kernel.org> - 2017-01-16 09:10 +0100
csiph-web