Re: Bad kernel mmap in perf

From: Arnaldo Carvalho de Melo
Date: Mon Jan 18 2010 - 09:24:38 EST

Em Mon, Jan 18, 2010 at 12:13:46AM +0100, Frederic Weisbecker escreveu:
> Hi!
> That doesn't look related to my previous problem,
> but I get another trouble:
> $ sudo ./perf sched record
> Couldn't record kernel reference relocation symbol.
> After investigating a bit, it looks like we ask
> event__synthesize_kernel_mmap() to find the kernel text
> mapping boudaries starting from the _text symbol.

Its not exactly to get the kernel boundaries, it could be any symbol that is
present everywhere, we'll just look at where it was at 'perf record' time and
then at 'perf report' time, when we may be using a vmlinux file, where the
values may not be the same due to relocation performed by things like kexec.

Look at:


> But I don't have _text in /proc/kallsyms, instead I
> have _stext.
> I'm not sure what's the difference between both, looks like
> between _text and _stext I'm supposed to have boot code? (which
> is then unlikely to be used by perf).
> That said the following patch fixes the issue, does that look
> sane to you?

yes, read more below

> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 7bb9ca1..49492f4 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -569,7 +569,7 @@ static int __cmd_record(int argc, const char **argv)
> }
> err = event__synthesize_kernel_mmap(process_synthesized_event,
> - session, "_text");
> + session, "_stext");

Its a good thing we encode the symbol name in the kernel MMAP fake event :-)

We need to find one symbol that is present in all arches, or use a fallback
mechanism to pick one present at 'perf record' time.

Checking here I have "_text" and "_stext" on two 32-bit machines:

[root@filo ~]# uname -a
Linux #1 SMP Thu Dec 24 16:26:26 UTC 2009 i686 athlon i386 GNU/Linux
[root@filo ~]# grep -w _text /proc/kallsyms
c0400000 T _text
[root@filo ~]# grep -w _stext /proc/kallsyms
c04010f0 T _stext
[root@filo ~]#

[acme@ana Downloads]$ uname -a
Linux #1 SMP Mon Dec 21 06:24:20 UTC 2009 i686 i686 i386 GNU/Linux
[acme@ana Downloads]$ grep -w _text /proc/kallsyms
c0400000 T _text
[acme@ana Downloads]$ grep -w _stext /proc/kallsyms
c04010e8 T _stext
[acme@ana Downloads]$

Also on ppc64:

[acme@bombadil ~]$ cat /etc/fedora-release
Fedora release 11 (Leonidas)
[acme@bombadil ~]$ uname -a
Linux #1 SMP Sat Oct 17 11:12:20 EDT 2009 ppc64 ppc64 ppc64 GNU/Linux
[acme@bombadil ~]$ grep -w _text /proc/kallsyms
c000000000000000 T _text
[acme@bombadil ~]$ grep -w _stext /proc/kallsyms
c000000000000000 T _stext
[acme@bombadil ~]$

And on parisc64:

acme@parisc:~$ cat /etc/debian_version
acme@parisc:~$ uname -a
Linux parisc 2.6.33-rc4-tip+ #3 SMP Sat Jan 16 15:26:28 BRST 2010 parisc64 GNU/Linux
acme@parisc:~$ grep -w _text /proc/kallsyms
0000000040100000 A _text
acme@parisc:~$ grep -w _stext /proc/kallsyms
0000000040100000 T _stext

And x86-64:

[acme@doppio linux-2.6-tip]$ cat /etc/fedora-release
Fedora release 11 (Leonidas)
[acme@doppio linux-2.6-tip]$ uname -a
Linux 2.6.33-rc4-tip+ #3 SMP Wed Jan 13 11:58:15 BRST 2010 x86_64 x86_64 x86_64 GNU/Linux
[acme@doppio linux-2.6-tip]$ grep -w _stext /proc/kallsyms
ffffffff81000190 T _stext
[acme@doppio linux-2.6-tip]$ grep -w _text /proc/kallsyms
ffffffff81000000 T _text
[acme@doppio linux-2.6-tip]$

So changing to "_stext" seems ok and files collected with it
as the "relocation reference symbol" will work with older perf binaries because
we encode the symbol name in the fake kernel MMAP event.

- Arnaldo
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at