All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: David Ahern <dsahern@gmail.com>
Cc: mingo@redhat.com, acme@ghostprotocols.net,
	a.p.zijlstra@chello.nl, paulus@samba.org, fweisbec@gmail.com,
	eranian@google.com, linux-kernel@vger.kernel.org
Subject: Re: [BUG PATCH] perf: kvm - finding struct machine fails for PERF_RECORD_MMAP
Date: Tue, 10 Apr 2012 09:10:33 +0530	[thread overview]
Message-ID: <87iph8xnim.fsf@abhimanyu.in.ibm.com> (raw)
In-Reply-To: <4F8369E6.5090608@gmail.com>

On Mon, 09 Apr 2012 16:59:50 -0600, David Ahern <dsahern@gmail.com> wrote:
> On 4/9/12 2:22 AM, Nikunj A. Dadhania wrote:
> > 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.
> 
> I have tried unsuccessfully to recreate the segfault. All of the samples 
> I get are of type PERF_RECORD_SAMPLE. I do not see how an MMAP event can 
> be generated in a guest context.
> 
I can think of two places where it can happen:

1) perf_event__synthesize_kernel_mmap

        [...]
 	mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff));
	if (machine__is_host(machine)) {
           ...
	} else {
		event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
		if (machine__is_default_guest(machine))
			filename = (char *) symbol_conf.default_guest_kallsyms;
		else {
			sprintf(path, "%s/proc/kallsyms", machine->root_dir);
			filename = path;
		}
	}
        [...]
	event->mmap.header.type = PERF_RECORD_MMAP;
        [...]
        event->mmap.pid   = machine->pid;        

2) perf_event__synthesize_modules

        [...]
	if (machine__is_host(machine))
		event->header.misc = PERF_RECORD_MISC_KERNEL;
	else
		event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
        [...]             
	event->mmap.header.type = PERF_RECORD_MMAP;
        [...]
        event->mmap.pid   = machine->pid;

BTW, i am testing this on latest -tip(498c911).

In my case, I am able to recreate this everytime. And have verified that
the event->header.type that I hit here is of type PERF_RECORD_MMAP.

Let me know if you want me to test out some debug patches.

Regards,
Nikunj


  reply	other threads:[~2012-04-10  3:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iph8xnim.fsf@abhimanyu.in.ibm.com \
    --to=nikunj@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.