Skip to contentSkip to conversation

maps mismatch in /proc/kcore for sparc

DISCUSSION David Ahern 2 participants 5 messages Mar 18, 2015 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

I am trying to understand why the perf tool on sparc fails to convert kernel symbols when /proc/kcore is used. I have instrumented perf to the point I can see that it drops symbols from kallsyms because it cannot find a corresponding map when the kernel maps are created based on parsing /proc/kcore.

For sparc kernel symbols start at 0x404000:

# less /proc/kallsyms
0000000000404000 T start
0000000000404000 T stext
0000000000404000 T _start
0000000000404000 T _stext
0000000000404000 T _text
0000000000404012 T root_flags
0000000000404014 T root_dev
0000000000404016 T ram_flags
0000000000404018 T sparc_ramdisk_image
000000000040401c T sparc_ramdisk_size
0000000000404030 T sparc_ramdisk_image64
000000000040403c t sparc64_boot
...

But 'objdump -x /proc/kcore' does not show a map covering 0x404000:

# objdump -x /proc/kcore

/proc/kcore: file format elf64-sparc
/proc/kcore
architecture: sparc:v9, flags 0x00000000:

start address 0x0000000000000000

Program Header:

     NOTE off    0x00000000000005b8 vaddr 0x0000000000000000 paddr 
0x0000000000000000 align 2**0
          filesz 0x0000000000001a3c memsz 0x0000000000000000 flags ---
     LOAD off    0x0008000100004000 vaddr 0x0000000100000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0005ffff00000000 memsz 0x0005ffff00000000 flags rwx
     LOAD off    0x0008000010004000 vaddr 0x0000000010000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x00000000e0000000 memsz 0x00000000e0000000 flags rwx
     LOAD off    0x00000000a0404000 vaddr 0xfff80000a0400000 paddr 
0x0000000000000000 align 2**13
          filesz 0x000000000f800000 memsz 0x000000000f800000 flags rwx
     LOAD off    0x000e00000140c000 vaddr 0x0006000001408000 paddr 
0x0000000000000000 align 2**13
          filesz 0x00000000001f0000 memsz 0x00000000001f0000 flags rwx
     LOAD off    0x00000000afd84000 vaddr 0xfff80000afd80000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000018000 memsz 0x0000000000018000 flags rwx
     LOAD off    0x000e0000015fe000 vaddr 0x00060000015fa000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000002000 memsz 0x0000000000002000 flags rwx
     LOAD off    0x00000020c0004000 vaddr 0xfff80020c0000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000040000000 memsz 0x0000000040000000 flags rwx
     LOAD off    0x000e000041804000 vaddr 0x0006000041800000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000800000 memsz 0x0000000000800000 flags rwx
     LOAD off    0x0000004250004000 vaddr 0xfff8004250000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000150000000 memsz 0x0000000150000000 flags rwx
     LOAD off    0x000e000084a04000 vaddr 0x0006000084a00000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000002a00000 memsz 0x0000000002a00000 flags rwx
     LOAD off    0x0000006000004000 vaddr 0xfff8006000000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000800000000 memsz 0x0000000800000000 flags rwx
     LOAD off    0x000e0000c0004000 vaddr 0x00060000c0000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000010000000 memsz 0x0000000010000000 flags rwx
     LOAD off    0x0000008170004000 vaddr 0xfff8008170000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000010000000 memsz 0x0000000010000000 flags rwx
     LOAD off    0x000e000102e04000 vaddr 0x0006000102e00000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000200000 memsz 0x0000000000200000 flags rwx
     LOAD off    0x000000a2d0004000 vaddr 0xfff800a2d0000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000060000000 memsz 0x0000000060000000 flags rwx
     LOAD off    0x000e000145a04000 vaddr 0x0006000145a00000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000c00000 memsz 0x0000000000c00000 flags rwx
     LOAD off    0x000000c340004000 vaddr 0xfff800c340000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000040000000 memsz 0x0000000040000000 flags rwx
     LOAD off    0x000e000186804000 vaddr 0x0006000186800000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000800000 memsz 0x0000000000800000 flags rwx
     LOAD off    0x000000e390004000 vaddr 0xfff800e390000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000530000000 memsz 0x0000000530000000 flags rwx
     LOAD off    0x000e0001c7204000 vaddr 0x00060001c7200000 paddr 
0x0000000000000000 align 2**13
          filesz 0x000000000a600000 memsz 0x000000000a600000 flags rwx
     LOAD off    0x0000010000004000 vaddr 0xfff8010000000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x000000007fd3e000 memsz 0x000000007fd3e000 flags rwx
     LOAD off    0x000e000200004000 vaddr 0x0006000200000000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000ffc000 memsz 0x0000000000ffc000 flags rwx
     LOAD off    0x000001007ffd2000 vaddr 0xfff801007ffce000 paddr 
0x0000000000000000 align 2**13
          filesz 0x000000000000a000 memsz 0x000000000000a000 flags rwx
     LOAD off    0x000e000201002000 vaddr 0x0006000200ffe000 paddr 
0x0000000000000000 align 2**13
          filesz 0x0000000000002000 memsz 0x0000000000002000 flags rwx

'objdump -x vmlinux' shows:

vmlinux: file format elf64-sparc
vmlinux
architecture: sparc:v9a, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000404000

Program Header:

     LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 
0x0000000000400000 align 2**20
          filesz 0x0000000000917b00 memsz 0x0000000000a2bd39 flags rwx
     NOTE off    0x000000000088de98 vaddr 0x0000000000c8de98 paddr 
0x0000000000c8de98 align 2**2
          filesz 0x0000000000000024 memsz 0x0000000000000024 flags r-x
    STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 
0x0000000000000000 align 2**3
          filesz 0x0000000000000000 memsz 0x0000000000000000 flags rwx

Any ideas on where it is going off the rails?

Thanks,
David

maintainer
#1 lore raw

From: David Ahern <[email protected]>
Date: Wed, 18 Mar 2015 10:56:22 -0600

Quoted 5 lines

I am trying to understand why the perf tool on sparc fails to convert kernel symbols when /proc/kcore is used. I have instrumented perf to the point I can see that it drops symbols from kallsyms because it cannot find a corresponding map when the kernel maps are created based on parsing /proc/kcore.

I'm looking into this, I think we need to set ARCH_PROC_KCORE_TEXT in arch/sparc/Kconfig

I have an even worse problem on my T4 system, /proc/kcore is zero length. Looking into that now as well.

#2 lore raw
Quoted 11 lines · David Miller

From: David Ahern <[email protected]>
Date: Wed, 18 Mar 2015 10:56:22 -0600

Quoted 5 lines

I am trying to understand why the perf tool on sparc fails to convert kernel symbols when /proc/kcore is used. I have instrumented perf to the point I can see that it drops symbols from kallsyms because it cannot find a corresponding map when the kernel maps are created based on parsing /proc/kcore.

I'm looking into this, I think we need to set ARCH_PROC_KCORE_TEXT in arch/sparc/Kconfig

Missed that config in my fumbling through the kcore code. Adding it to sparc/Kconfig and it works. map is added:

kcore_mapfn: dso [kernel.kallsyms]: new map from 404000 to e33d79

and kernel symbols are not dropped. One mystery solved.

Thanks,
David

maintainer
#3 lore raw

From: David Ahern <[email protected]>
Date: Wed, 18 Mar 2015 13:57:59 -0600

Quoted 13 lines · David Miller
Quoted 11 lines

From: David Ahern <[email protected]>
Date: Wed, 18 Mar 2015 10:56:22 -0600

Quoted 5 lines

I am trying to understand why the perf tool on sparc fails to convert kernel symbols when /proc/kcore is used. I have instrumented perf to the point I can see that it drops symbols from kallsyms because it cannot find a corresponding map when the kernel maps are created based on parsing /proc/kcore.

I'm looking into this, I think we need to set ARCH_PROC_KCORE_TEXT in arch/sparc/Kconfig

Quoted 6 lines

Missed that config in my fumbling through the kcore code. Adding it to sparc/Kconfig and it works. map is added:

kcore_mapfn: dso [kernel.kallsyms]: new map from 404000 to e33d79

and kernel symbols are not dropped. One mystery solved.

I'm really wondering how you have a non-zero-length /proc/kcore file, do you have any local changes in your tree?

I ask because no memory regions should be added until we add the "System RAM" entries to /proc/iomem, and this is done by report_memory() in arch/sparc/mm/init_64.c which is a device_initcall().

The kcore core that looks for that stuff is an fs_initcall() which runs earlier, and thus won't see any entries at all.

You have something different in your tree if kcore is actually finding memory to add to the kcore memory lists.

Oh I see, you're using older sources which don't have:

	commit abaf3787ac26ba33e2f75e76b1174c32254c25b0
	Author: Paul Gortmaker <[email protected]>
	Date:   Thu Jan 23 15:55:45 2014 -0800

	    fs/proc: don't use module_init for non-modular core code

And that explains everything, I'll submit the following:

arch/sparc/Kconfig +3 -0
index 96ac69c..efb00ec 100644
@@ -86,6 +86,9 @@ config ARCH_DEFCONFIG
 	default "arch/sparc/configs/sparc32_defconfig" if SPARC32
 	default "arch/sparc/configs/sparc64_defconfig" if SPARC64
 
+config ARCH_PROC_KCORE_TEXT
+	def_bool y
+
 config IOMMU_HELPER
 	bool
 	default y if SPARC64
arch/sparc/mm/init_64.c +1 -1
index 3ea267c..4ca0d6b 100644
@@ -2820,7 +2820,7 @@ static int __init report_memory(void)
 
 	return 0;
 }
-device_initcall(report_memory);
+arch_initcall(report_memory);
 
 #ifdef CONFIG_SMP
 #define do_flush_tlb_kernel_range	smp_flush_tlb_kernel_range
#4 lore raw
Quoted 7 lines · David Miller

Oh I see, you're using older sources which don't have:

	commit abaf3787ac26ba33e2f75e76b1174c32254c25b0
	Author: Paul Gortmaker <[email protected]>
	Date:   Thu Jan 23 15:55:45 2014 -0800

	    fs/proc: don't use module_init for non-modular core code

Interesting.

# git describe abaf3787ac26ba33e2f75e76b1174c32254c25b0
v3.13-4322-gabaf3787ac26

I am running 3.18 and that patch has been applied to the tree.

Looking at 4.0.0-rc3 and I do see the 0-length problem. Perhaps another defect is the root cause?

Regardless the below works.

David

Quoted 31 lines

And that explains everything, I'll submit the following:

arch/sparc/Kconfig +3 -0
index 96ac69c..efb00ec 100644
@@ -86,6 +86,9 @@ config ARCH_DEFCONFIG
  	default "arch/sparc/configs/sparc32_defconfig" if SPARC32
  	default "arch/sparc/configs/sparc64_defconfig" if SPARC64
 
+config ARCH_PROC_KCORE_TEXT
+	def_bool y
+
  config IOMMU_HELPER
  	bool
  	default y if SPARC64
arch/sparc/mm/init_64.c +1 -1
index 3ea267c..4ca0d6b 100644
@@ -2820,7 +2820,7 @@ static int __init report_memory(void)
 
  	return 0;
  }
-device_initcall(report_memory);
+arch_initcall(report_memory);
 
  #ifdef CONFIG_SMP
  #define do_flush_tlb_kernel_range	smp_flush_tlb_kernel_range