All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG PATCH] perf: kvm - finding struct machine fails for PERF_RECORD_MMAP
@ 2012-04-09  8:22 Nikunj A. Dadhania
  2012-04-09 20:17 ` David Ahern
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nikunj A. Dadhania @ 2012-04-09  8:22 UTC (permalink / raw)
  To: mingo, acme, dsahern
  Cc: a.p.zijlstra, paulus, fweisbec, eranian, linux-kernel, nikunj

From: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>

Running 'perf kvm --host --guest --guestmount /tmp/guestmount record -a -g -- sleep 2'

Was resulting in a segfault. For event type PERF_RECORD_MMAP,
event->ip.pid is being used in perf_session__find_machine_for_cpumode,
which is not correct.

event->ip.pid happens to be 0 in this case and results in returning a
NULL machine object. Finally, access to self->pid in
machine__mmap_name, results in a segfault later.

For PERF_RECORD_MMAP type, pass event->mmap.pid.

Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
---

 tools/perf/util/session.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 9412e3b..00923cd 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -826,8 +826,16 @@ static struct machine *
 {
 	const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
 
-	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest)
-		return perf_session__find_machine(session, event->ip.pid);
+	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
+		u32 pid;
+
+		if (event->header.type == PERF_RECORD_MMAP)
+			pid = event->mmap.pid;
+		else
+			pid = event->ip.pid;
+
+		return perf_session__find_machine(session, pid);
+	}
 
 	return perf_session__find_host_machine(session);
 }


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

end of thread, other threads:[~2012-04-13 18:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09  8:22 [BUG PATCH] perf: kvm - finding struct machine fails for PERF_RECORD_MMAP Nikunj A. Dadhania
2012-04-09 20:17 ` David Ahern
2012-04-09 22:59 ` David Ahern
2012-04-10  3:40   ` Nikunj A Dadhania
2012-04-10 15:14     ` David Ahern
2012-04-10 15:16 ` David Ahern
2012-04-11 14:47   ` Arnaldo Carvalho de Melo
2012-04-13 18:13 ` [tip:perf/urgent] perf kvm: Finding " tip-bot for Nikunj A. Dadhania

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.