* [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file
@ 2023-06-28 8:45 Georg Müller
2023-06-28 8:45 ` [PATCH v3 1/2] perf probe: add test for " Georg Müller
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Georg Müller @ 2023-06-28 8:45 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, Masami Hiramatsu (Google)
Cc: Georg Müller, regressions, Arnaldo Carvalho de Melo,
linux-perf-users, linux-kernel
When switching from dwarf_decl_file() to die_get_decl_file(), a regression
was introduced when having a binary where the DWARF info is split to
multiple CUs. It is not possible to add probes to certain functions.
These patches introduce a testcase which shows the current regression
and a fix for the issue
Signed-off-by: Georg Müller <georgmueller@gmx.net>
Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
---
Changes in v2:
- Add testcase
Changes in v3:
- start new thread
- add stable to cc
Georg Müller (2):
perf probe: add test for regression introduced by switch to
die_get_decl_file
perf probe: read DWARF files from the correct CU
.../shell/test_uprobe_from_different_cu.sh | 77 +++++++++++++++++++
tools/perf/util/dwarf-aux.c | 4 +-
2 files changed, 80 insertions(+), 1 deletion(-)
create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] perf probe: add test for regression introduced by switch to die_get_decl_file
2023-06-28 8:45 [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Georg Müller
@ 2023-06-28 8:45 ` Georg Müller
2023-06-28 8:45 ` [PATCH v3 2/2] perf probe: read DWARF files from the correct CU Georg Müller
2023-07-10 12:32 ` [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Linux regression tracking (Thorsten Leemhuis)
2 siblings, 0 replies; 6+ messages in thread
From: Georg Müller @ 2023-06-28 8:45 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, Masami Hiramatsu (Google)
Cc: Georg Müller, regressions, Arnaldo Carvalho de Melo,
linux-perf-users, linux-kernel, stable
This patch adds a test to validate that perf probe works for binaries
where DWARF info is split into multiple CUs
Signed-off-by: Georg Müller <georgmueller@gmx.net>
Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
Cc: stable@vger.kernel.org
---
.../shell/test_uprobe_from_different_cu.sh | 77 +++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
diff --git a/tools/perf/tests/shell/test_uprobe_from_different_cu.sh b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
new file mode 100755
index 000000000000..00d2e0e2e0c2
--- /dev/null
+++ b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+# test perf probe of function from different CU
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
+
+cleanup()
+{
+ trap - EXIT TERM INT
+ if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
+ echo "--- Cleaning up ---"
+ perf probe -x ${temp_dir}/testfile -d foo
+ rm -f "${temp_dir}/"*
+ rmdir "${temp_dir}"
+ fi
+}
+
+trap_cleanup()
+{
+ cleanup
+ exit 1
+}
+
+trap trap_cleanup EXIT TERM INT
+
+cat > ${temp_dir}/testfile-foo.h << EOF
+struct t
+{
+ int *p;
+ int c;
+};
+
+extern int foo (int i, struct t *t);
+EOF
+
+cat > ${temp_dir}/testfile-foo.c << EOF
+#include "testfile-foo.h"
+
+int
+foo (int i, struct t *t)
+{
+ int j, res = 0;
+ for (j = 0; j < i && j < t->c; j++)
+ res += t->p[j];
+
+ return res;
+}
+EOF
+
+cat > ${temp_dir}/testfile-main.c << EOF
+#include "testfile-foo.h"
+
+static struct t g;
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ int j[argc];
+ g.c = argc;
+ g.p = j;
+ for (i = 0; i < argc; i++)
+ j[i] = (int) argv[i][0];
+ return foo (3, &g);
+}
+EOF
+
+gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
+gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
+gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
+
+perf probe -x ${temp_dir}/testfile --funcs foo
+perf probe -x ${temp_dir}/testfile foo
+
+cleanup
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] perf probe: read DWARF files from the correct CU
2023-06-28 8:45 [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Georg Müller
2023-06-28 8:45 ` [PATCH v3 1/2] perf probe: add test for " Georg Müller
@ 2023-06-28 8:45 ` Georg Müller
2023-07-10 12:32 ` [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Linux regression tracking (Thorsten Leemhuis)
2 siblings, 0 replies; 6+ messages in thread
From: Georg Müller @ 2023-06-28 8:45 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter, Masami Hiramatsu (Google)
Cc: Georg Müller, regressions, Arnaldo Carvalho de Melo,
linux-perf-users, linux-kernel, stable
After switching from dwarf_decl_file() to die_get_decl_file(), it is not
possible to add probes for certain functions:
$ perf probe -x /usr/lib/systemd/systemd-logind match_unit_removed
A function DIE doesn't have decl_line. Maybe broken DWARF?
A function DIE doesn't have decl_line. Maybe broken DWARF?
Probe point 'match_unit_removed' not found.
Error: Failed to add events.
The problem is that die_get_decl_file() uses the wrong CU to search for
the file. elfutils commit e1db5cdc9f has some good explanation for this:
dwarf_decl_file uses dwarf_attr_integrate to get the DW_AT_decl_file
attribute. This means the attribute might come from a different DIE
in a different CU. If so, we need to use the CU associated with the
attribute, not the original DIE, to resolve the file name.
This patch uses the same source of information as elfutils: use attribute
DW_AT_decl_file and use this CU to search for the file.
Fixes: dc9a5d2ccd5c ("perf probe: Fix to get declared file name from clang DWARF5")
Signed-off-by: Georg Müller <georgmueller@gmx.net>
Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
Cc: stable@vger.kernel.org
---
tools/perf/util/dwarf-aux.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index b07414409771..137b3ed9897b 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -478,8 +478,10 @@ static const char *die_get_file_name(Dwarf_Die *dw_die, int idx)
{
Dwarf_Die cu_die;
Dwarf_Files *files;
+ Dwarf_Attribute attr_mem;
- if (idx < 0 || !dwarf_diecu(dw_die, &cu_die, NULL, NULL) ||
+ if (idx < 0 || !dwarf_attr_integrate(dw_die, DW_AT_decl_file, &attr_mem) ||
+ !dwarf_cu_die(attr_mem.cu, &cu_die, NULL, NULL, NULL, NULL, NULL, NULL) ||
dwarf_getsrcfiles(&cu_die, &files, NULL) != 0)
return NULL;
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file
2023-06-28 8:45 [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Georg Müller
2023-06-28 8:45 ` [PATCH v3 1/2] perf probe: add test for " Georg Müller
2023-06-28 8:45 ` [PATCH v3 2/2] perf probe: read DWARF files from the correct CU Georg Müller
@ 2023-07-10 12:32 ` Linux regression tracking (Thorsten Leemhuis)
2023-07-10 13:44 ` Arnaldo Carvalho de Melo
2 siblings, 1 reply; 6+ messages in thread
From: Linux regression tracking (Thorsten Leemhuis) @ 2023-07-10 12:32 UTC (permalink / raw)
To: Georg Müller, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
Jiri Olsa, Namhyung Kim, Ian Rogers, Adrian Hunter,
Masami Hiramatsu (Google)
Cc: regressions, Arnaldo Carvalho de Melo, linux-perf-users,
linux-kernel
Hi, Thorsten here, the Linux kernel's regression tracker. Top-posting
for once, to make this easily accessible to everyone.
Masami, Arnaldo, what's up here? Georg (who is not a regular
contributor) afaics found a regression in a commit you
authored/committed and even provided a patch-set to fix it (the first
one nearly four weeks ago, e.g. before the merge window started), but
hasn't received much support from your side to get this in. Could you
please look into this to get this cleared up? Or am I missing something
and progress to fix this has been made?
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.
On 28.06.23 10:45, Georg Müller wrote:
> When switching from dwarf_decl_file() to die_get_decl_file(), a regression
> was introduced when having a binary where the DWARF info is split to
> multiple CUs. It is not possible to add probes to certain functions.
>
> These patches introduce a testcase which shows the current regression
> and a fix for the issue
>
> Signed-off-by: Georg Müller <georgmueller@gmx.net>
> Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
>
> ---
> Changes in v2:
> - Add testcase
>
> Changes in v3:
> - start new thread
> - add stable to cc
>
> Georg Müller (2):
> perf probe: add test for regression introduced by switch to
> die_get_decl_file
> perf probe: read DWARF files from the correct CU
>
> .../shell/test_uprobe_from_different_cu.sh | 77 +++++++++++++++++++
> tools/perf/util/dwarf-aux.c | 4 +-
> 2 files changed, 80 insertions(+), 1 deletion(-)
> create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
>
> --
> 2.41.0
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file
2023-07-10 12:32 ` [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Linux regression tracking (Thorsten Leemhuis)
@ 2023-07-10 13:44 ` Arnaldo Carvalho de Melo
2023-07-10 13:49 ` Linux regression tracking (Thorsten Leemhuis)
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-07-10 13:44 UTC (permalink / raw)
To: Linux regressions mailing list
Cc: Georg Müller, Peter Zijlstra, Ingo Molnar, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Namhyung Kim, Ian Rogers,
Adrian Hunter, Masami Hiramatsu (Google),
Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel
Em Mon, Jul 10, 2023 at 02:32:28PM +0200, Linux regression tracking (Thorsten Leemhuis) escreveu:
> Hi, Thorsten here, the Linux kernel's regression tracker. Top-posting
> for once, to make this easily accessible to everyone.
>
> Masami, Arnaldo, what's up here? Georg (who is not a regular
> contributor) afaics found a regression in a commit you
> authored/committed and even provided a patch-set to fix it (the first
> one nearly four weeks ago, e.g. before the merge window started), but
> hasn't received much support from your side to get this in. Could you
> please look into this to get this cleared up? Or am I missing something
> and progress to fix this has been made?
I'm back from a 2 week vacation, going thru the pile, probably fell thru
the cracks and Namyung, that processed patches while I was away didn't
notice it either.
I'm checking,
- Arnaldo
> Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
> --
> Everything you wanna know about Linux kernel regression tracking:
> https://linux-regtracking.leemhuis.info/about/#tldr
> If I did something stupid, please tell me, as explained on that page.
>
>
> On 28.06.23 10:45, Georg Müller wrote:
> > When switching from dwarf_decl_file() to die_get_decl_file(), a regression
> > was introduced when having a binary where the DWARF info is split to
> > multiple CUs. It is not possible to add probes to certain functions.
> >
> > These patches introduce a testcase which shows the current regression
> > and a fix for the issue
> >
> > Signed-off-by: Georg Müller <georgmueller@gmx.net>
> > Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
> >
> > ---
> > Changes in v2:
> > - Add testcase
> >
> > Changes in v3:
> > - start new thread
> > - add stable to cc
> >
> > Georg Müller (2):
> > perf probe: add test for regression introduced by switch to
> > die_get_decl_file
> > perf probe: read DWARF files from the correct CU
> >
> > .../shell/test_uprobe_from_different_cu.sh | 77 +++++++++++++++++++
> > tools/perf/util/dwarf-aux.c | 4 +-
> > 2 files changed, 80 insertions(+), 1 deletion(-)
> > create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
> >
> > --
> > 2.41.0
> >
> >
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file
2023-07-10 13:44 ` Arnaldo Carvalho de Melo
@ 2023-07-10 13:49 ` Linux regression tracking (Thorsten Leemhuis)
0 siblings, 0 replies; 6+ messages in thread
From: Linux regression tracking (Thorsten Leemhuis) @ 2023-07-10 13:49 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Linux regressions mailing list
Cc: Georg Müller, Peter Zijlstra, Ingo Molnar, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Namhyung Kim, Ian Rogers,
Adrian Hunter, Masami Hiramatsu (Google),
Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel
On 10.07.23 15:44, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jul 10, 2023 at 02:32:28PM +0200, Linux regression tracking (Thorsten Leemhuis) escreveu:
>> Hi, Thorsten here, the Linux kernel's regression tracker. Top-posting
>> for once, to make this easily accessible to everyone.
>>
>> Masami, Arnaldo, what's up here? Georg (who is not a regular
>> contributor) afaics found a regression in a commit you
>> authored/committed and even provided a patch-set to fix it (the first
>> one nearly four weeks ago, e.g. before the merge window started), but
>> hasn't received much support from your side to get this in. Could you
>> please look into this to get this cleared up? Or am I missing something
>> and progress to fix this has been made?
>
> I'm back from a 2 week vacation,
Welcome back and hope you found some rest.
> going thru the pile, probably fell thru
> the cracks and Namyung, that processed patches while I was away didn't
> notice it either.
>
> I'm checking,
Great, many thx! Ciao, Thorsten
>> Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
>> --
>> Everything you wanna know about Linux kernel regression tracking:
>> https://linux-regtracking.leemhuis.info/about/#tldr
>> If I did something stupid, please tell me, as explained on that page.
>>
>>
>> On 28.06.23 10:45, Georg Müller wrote:
>>> When switching from dwarf_decl_file() to die_get_decl_file(), a regression
>>> was introduced when having a binary where the DWARF info is split to
>>> multiple CUs. It is not possible to add probes to certain functions.
>>>
>>> These patches introduce a testcase which shows the current regression
>>> and a fix for the issue
>>>
>>> Signed-off-by: Georg Müller <georgmueller@gmx.net>
>>> Link: https://lore.kernel.org/r/5a00d5a5-7be7-ef8a-4044-9a16249fff25@gmx.net/
>>>
>>> ---
>>> Changes in v2:
>>> - Add testcase
>>>
>>> Changes in v3:
>>> - start new thread
>>> - add stable to cc
>>>
>>> Georg Müller (2):
>>> perf probe: add test for regression introduced by switch to
>>> die_get_decl_file
>>> perf probe: read DWARF files from the correct CU
>>>
>>> .../shell/test_uprobe_from_different_cu.sh | 77 +++++++++++++++++++
>>> tools/perf/util/dwarf-aux.c | 4 +-
>>> 2 files changed, 80 insertions(+), 1 deletion(-)
>>> create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
>>>
>>> --
>>> 2.41.0
>>>
>>>
>>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-10 13:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 8:45 [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Georg Müller
2023-06-28 8:45 ` [PATCH v3 1/2] perf probe: add test for " Georg Müller
2023-06-28 8:45 ` [PATCH v3 2/2] perf probe: read DWARF files from the correct CU Georg Müller
2023-07-10 12:32 ` [PATCH v3 0/2] perf probe: fix regression introduced by switch to die_get_decl_file Linux regression tracking (Thorsten Leemhuis)
2023-07-10 13:44 ` Arnaldo Carvalho de Melo
2023-07-10 13:49 ` Linux regression tracking (Thorsten Leemhuis)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox