All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] perf report: ensure the perf DSO mapping matches what libdw sees
@ 2017-06-02 14:37 Milian Wolff
  2017-06-02 14:37 ` [PATCH 2/2] perf report: report module before querying isactivation in dwfl unwind Milian Wolff
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Milian Wolff @ 2017-06-02 14:37 UTC (permalink / raw)
  To: Linux-kernel
  Cc: linux-perf-users, Milian Wolff, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa

In some situations the libdw unwinder stopped working properly.
I.e. with libunwind we see:

~~~~~
heaptrack_gui  2228 135073.400112:     641314 cycles:
	            e8ed _dl_fixup (/usr/lib/ld-2.25.so)
	           15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
	           ed94c KDynamicJobTracker::KDynamicJobTracker (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
	           608f3 _GLOBAL__sub_I_kdynamicjobtracker.cpp (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
	            f199 call_init.part.0 (/usr/lib/ld-2.25.so)
	            f2a5 _dl_init (/usr/lib/ld-2.25.so)
	             db9 _dl_start_user (/usr/lib/ld-2.25.so)
~~~~~

But with libdw and without this patch this sample is not properly
unwound:

~~~~~
heaptrack_gui  2228 135073.400112:     641314 cycles:
	            e8ed _dl_fixup (/usr/lib/ld-2.25.so)
	           15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
	           ed94c KDynamicJobTracker::KDynamicJobTracker (/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
~~~~~

Debug output showed me that libdw found a module for the last frame
address, but it thinks it belongs to /usr/lib/ld-2.25.so. This patch
double-checks what libdw sees and what perf knows. If the mappings
mismatch, we now report the elf known to perf. This fixes the
situation above, and the libdw unwinder produces the same stack as
libunwind.

Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
---
 tools/perf/util/unwind-libdw.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index b4c20124d2ee..da45c4be5fb3 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -39,6 +39,14 @@ static int __report_module(struct addr_location *al, u64 ip,
 		return 0;
 
 	mod = dwfl_addrmodule(ui->dwfl, ip);
+	if (mod) {
+		Dwarf_Addr s;
+
+		dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL);
+		if (s != al->map->start)
+			mod = 0;
+	}
+
 	if (!mod)
 		mod = dwfl_report_elf(ui->dwfl, dso->short_name,
 				      dso->long_name, -1, al->map->start,
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-06-16 19:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 14:37 [PATCH 1/2] perf report: ensure the perf DSO mapping matches what libdw sees Milian Wolff
2017-06-02 14:37 ` [PATCH 2/2] perf report: report module before querying isactivation in dwfl unwind Milian Wolff
2017-06-02 15:25   ` Arnaldo Carvalho de Melo
2017-06-05 10:47     ` Jiri Olsa
2017-06-15 19:20       ` Jan Kratochvil
2017-06-16 16:06     ` Arnaldo Carvalho de Melo
2017-06-16 17:36       ` Arnaldo Carvalho de Melo
2017-06-16 19:38   ` [tip:perf/urgent] perf unwind: Report " tip-bot for Milian Wolff
2017-06-02 15:23 ` [PATCH 1/2] perf report: ensure the perf DSO mapping matches what libdw sees Arnaldo Carvalho de Melo
2017-06-02 16:21   ` Milian Wolff
2017-06-02 19:49     ` Arnaldo Carvalho de Melo
2017-06-03 11:36       ` Milian Wolff
2017-06-05 10:41 ` Jiri Olsa
2017-06-15 20:38   ` Jan Kratochvil
2017-06-07 16:01 ` [tip:perf/urgent] perf report: Ensure " tip-bot for Milian Wolff

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.