All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Wang Nan <wangnan0@huawei.com>,
	namhyung@kernel.org, jolsa@kernel.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org, pi3orama@163.com
Subject: Re: [PATCH v2] perf: report/annotate: fix segfault problem.
Date: Mon, 6 Apr 2015 09:52:39 -0300	[thread overview]
Message-ID: <20150406125239.GE2500@redhat.com> (raw)
In-Reply-To: <20150403105721.GB5571@krava.brq.redhat.com>

Em Fri, Apr 03, 2015 at 12:57:21PM +0200, Jiri Olsa escreveu:
> On Fri, Apr 03, 2015 at 05:56:25AM +0000, Wang Nan wrote:
> > perf report and perf annotate are easy to trigger segfault if trace data
> > contain kernel module information like this:

> >  # perf report -D -i ./perf.data

> >  0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module]

> oops, I was wondering how you'd get such a MMAP record, because we lookup
> modules real paths and store it.. I haven't realized that if we dont find
> it we keep the '[mod]' name :-\
 
> SNIP
 
> > Patch v1 doesn't consider module named as [aaa.bbb].

> >  tools/perf/util/dso.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> > @@ -214,12 +214,23 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
> >  {
> >  	const char *name = strrchr(path, '/');
> >  	const char *ext  = strrchr(path, '.');
> > +	bool is_simple_name = false;
> >  
> >  	memset(m, 0x0, sizeof(*m));
> >  	name = name ? name + 1 : path;
> >  
> > +	/*
> > +	 * '.' is also a valid character. For example: [aaa.bbb] is a
> > +	 * valid module name. '[' should have higher priority than
> > +	 * '.ko' suffix.
> > +	 */
> 
> 
> > +	if ((name[0] == '[') &&	(strncmp(name, "[vdso]", 6) != 0)) {
> 
> maybe also check for '[vsyscall]' ?

I wonder if there are more? Possibly we should look at some other field
to figure it out if this is kernel code, perhaps use this that is set
when synthesizing a module:

        if (machine__is_host(machine))
                event->header.misc = PERF_RECORD_MISC_KERNEL;
        else
                event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;

?
 
> > +		m->kmod = true;
> > +		is_simple_name = true;
> > +	}
> > +
> >  	/* No extension, just return name. */
> > -	if (ext == NULL) {
> > +	if ((ext == NULL) || is_simple_name) {
> >  		if (alloc_name) {
> >  			m->name = strdup(name);
> >  			return m->name ? 0 : -ENOMEM;
> 
> otherwise it looks ok to me.. please update also the tests/kmod-path.c ;-)
> 
> thanks,
> jirka

  reply	other threads:[~2015-04-06 12:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03  5:56 [PATCH v2] perf: report/annotate: fix segfault problem Wang Nan
2015-04-03  6:48 ` Ingo Molnar
2015-04-03  8:47   ` [PATCH] perf: kmaps: enforce usage of kmaps to protect futher bugs Wang Nan
2015-04-03  8:49     ` Ingo Molnar
2015-04-03 11:11     ` Jiri Olsa
2015-04-07 10:42       ` Adrian Hunter
2015-04-08 10:50         ` [PATCH v4] " Wang Nan
2015-04-03  9:07 ` [PATCH v2] perf: report/annotate: fix segfault problem Jiri Olsa
2015-04-03 10:57 ` Jiri Olsa
2015-04-06 12:52   ` Arnaldo Carvalho de Melo [this message]
2015-04-07  8:22     ` [PATCH v3 0/2] " Wang Nan
2015-04-07  8:22       ` [PATCH v3 1/2] perf: kmaps: enforce usage of kmaps to protect futher bugs Wang Nan
2015-04-08 15:10         ` [tip:perf/core] perf kmaps: Check kmaps to make code more robust tip-bot for Wang Nan
2015-04-07  8:22       ` [PATCH v3 2/2] perf: report/annotate: fix segfault problem Wang Nan
2015-04-07 15:13         ` Arnaldo Carvalho de Melo
2015-04-08  3:49           ` Wang Nan
2015-04-08  3:52           ` [PATCH v4 " Wang Nan
2015-04-08 13:59             ` Jiri Olsa
2015-04-09  7:05               ` Wang Nan
2015-04-09 11:40                 ` Jiri Olsa
2015-04-09 11:52             ` Jiri Olsa
2015-04-10  1:57               ` Wang Nan
2015-04-10  2:49               ` Wang Nan
2015-04-10  3:53               ` [PATCH v5 " Wang Nan
2015-04-15  1:27                 ` Wang Nan
2015-04-20  1:18                   ` Wang Nan

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=20150406125239.GE2500@redhat.com \
    --to=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /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.