Re: [PATCH 5.4 245/434] perf probe: Fix to list probe event with correct line number

From: Masami Hiramatsu
Date: Mon Dec 30 2019 - 04:14:28 EST


On Mon, 30 Dec 2019 01:00:14 +0200
Thomas Backlund <tmb@xxxxxxxxxx> wrote:

> Den 29-12-2019 kl. 20:42, skrev Thomas Backlund:
> > Den 29-12-2019 kl. 19:24, skrev Greg Kroah-Hartman:
> >> From: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> >>
> >> [ Upstream commit 3895534dd78f0fd4d3f9e05ee52b9cdd444a743e ]
> >>
> >> Since debuginfo__find_probe_point() uses dwarf_entrypc() for finding the
> >> entry address of the function on which a probe is, it will fail when the
> >> function DIE has only ranges attribute.
> >>
> >> To fix this issue, use die_entrypc() instead of dwarf_entrypc().
> >>
> >> Without this fix, perf probe -l shows incorrect offset:
> >>
> >> ÂÂ # perf probe -l
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask (on
> >> clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
> >>
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask_1 (on
> >> clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)
> >>
> >>
> >> With this:
> >>
> >> ÂÂ # perf probe -l
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask (on
> >> clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask_1 (on
> >> clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)
> >>
> >> Committer testing:
> >>
> >> Before:
> >>
> >> ÂÂ [root@quaco ~]# perf probe -l
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask (on
> >> clear_tasks_mm_cpumask+18446744071579765152@kernel/cpu.c)
> >> ÂÂ [root@quaco ~]#
> >>
> >> After:
> >>
> >> ÂÂ [root@quaco ~]# perf probe -l
> >> ÂÂÂÂ probe:clear_tasks_mm_cpumask (on
> >> clear_tasks_mm_cpumask@kernel/cpu.c)
> >> ÂÂ [root@quaco ~]#
> >>
> >> Fixes: 1d46ea2a6a40 ("perf probe: Fix listing incorrect line number
> >> with inline function")
> >> Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> >> Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> >> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> >> Link:
> >> http://lore.kernel.org/lkml/157199321227.8075.14655572419136993015.stgit@devnote2
> >>
> >> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> >> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> >> ---
> >> Â tools/perf/util/probe-finder.c | 4 ++--
> >> Â 1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/tools/perf/util/probe-finder.c
> >> b/tools/perf/util/probe-finder.c
> >> index cd9f95e5044e..7c8d30fb2b99 100644
> >> --- a/tools/perf/util/probe-finder.c
> >> +++ b/tools/perf/util/probe-finder.c
> >> @@ -1578,7 +1578,7 @@ int debuginfo__find_probe_point(struct debuginfo
> >> *dbg, unsigned long addr,
> >> ÂÂÂÂÂÂÂÂÂ /* Get function entry information */
> >> ÂÂÂÂÂÂÂÂÂ func = basefunc = dwarf_diename(&spdie);
> >> ÂÂÂÂÂÂÂÂÂ if (!func ||
> >> -ÂÂÂÂÂÂÂÂÂÂÂ dwarf_entrypc(&spdie, &baseaddr) != 0 ||
> >> +ÂÂÂÂÂÂÂÂÂÂÂ die_entrypc(&spdie, &baseaddr) != 0 ||
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂ dwarf_decl_line(&spdie, &baseline) != 0) {
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂ lineno = 0;
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂ goto post;
> >> @@ -1595,7 +1595,7 @@ int debuginfo__find_probe_point(struct debuginfo
> >> *dbg, unsigned long addr,
> >> ÂÂÂÂÂÂÂÂÂ while (die_find_top_inlinefunc(&spdie, (Dwarf_Addr)addr,
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &indie)) {
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂ /* There is an inline function */
> >> -ÂÂÂÂÂÂÂÂÂÂÂ if (dwarf_entrypc(&indie, &_addr) == 0 &&
> >> +ÂÂÂÂÂÂÂÂÂÂÂ if (die_entrypc(&indie, &_addr) == 0 &&
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ _addr == addr) {
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /*
> >> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ * addr is at an inline function entry.
> >>
> >
> >
> > still broken
> >
> > /usr/bin/ld: perf-in.o: in function `debuginfo__find_probe_point':
> > /work/rpmbuild/BUILD/kernel-x86_64/linux-5.4/tools/perf/util/probe-finder.c:1616:
> > undefined reference to `die_entrypc'
> >
>
>
> And the fix for the perf build errors I reported against:
> [PATCH 5.4 245/434] perf probe: Fix to list probe event with correct
> line number
> [PATCH 5.4 248/434] perf probe: Fix to probe an inline function which
> has no entry pc
> [PATCH 5.4 249/434] perf probe: Fix to show ranges of variables in
> functions without entry_pc
> [PATCH 5.4 250/434] perf probe: Fix to show inlined function callsite
> without entry_pc
> [PATCH 5.4 252/434] perf probe: Fix to probe a function which has no
> entry pc
>
> is to add the missing:
>
> From 91e2f539eeda26ab00bd03fae8dc434c128c85ed Mon Sep 17 00:00:00 2001
> From: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> Date: Thu, 24 Oct 2019 18:12:54 +0900
> Subject: [PATCH] perf probe: Fix to show function entry line as probe-able

Thanks Thomas, you're right.
The die_entrypc() was newly added by that commit for finding correct
entry PC of functions.

Greg, could you please apply above fix too?

Thank you,

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>