Skip to contentSkip to conversation

Bad kernel mmap in perf

DISCUSSION Arnaldo Carvalho de Melo 1 participant 1 message Jan 18, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20100117231345.GJ5035@nowhere

#1 lore raw

Em Mon, Jan 18, 2010 at 12:13:46AM +0100, Frederic Weisbecker escreveu:

Quoted 11 lines

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:

        dso__load_sym() 
                perf_session__reloc_vmlinux_maps()
Quoted 9 lines

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

tools/perf/builtin-record.c static int __cmd_record(int argc, const char **argv) · line 572

Quoted 10 lines
tools/perf/builtin-record.c +1 -1
index 7bb9ca1..49492f4 100644
@@ -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 filo.ghostprotocols.net 2.6.30.10-105.fc11.i586 #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 ana.ghostprotocols.net 2.6.31.9-174.fc12.i686 #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 bombadil.infradead.org 2.6.30.9-90.fc11.ppc64 #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 
squeeze/sid
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
acme@parisc:~$

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 doppio.ghostprotocols.net 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 perf.data 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