>> I think the Michael's first idea below is better since it implements >> is_real_addr() only for --mem-usage as a common function for all >> architectures, it's explicit design. >> >> >@@ -854,7 +854,7 @@ int get_kcore_dump_loads(void) >> > >> > for (i = 0; i < num_pt_loads; ++i) { >> > struct pt_load_segment *p = &pt_loads[i]; >> >- if (is_vmalloc_addr(p->virt_start)) >> >+ if (!is_real_addr(p->virt_start)) >> > continue; >> > loads++; >> > } >> >> However, this code will not work since the argument of is_real_addr() >> must be physical address. Even unluckily, /proc/kcore's PT_LOAD looks >> useless for VtoP converting because PhysAddr is always 0: >> >> Program Headers: >> Type Offset VirtAddr PhysAddr >> FileSiz MemSiz Flags Align >> NOTE 0x00000000000002a8 0x0000000000000000 0x0000000000000000 >> 0x0000000000000a84 0x0000000000000000 0 >> LOAD 0x00007fffff601000 0xffffffffff600000 0x0000000000000000 >> 0x0000000000001000 0x0000000000001000 RWE 1000 >> LOAD 0x00007fff81001000 0xffffffff81000000 0x0000000000000000 >> 0x0000000000a1b000 0x0000000000a1b000 RWE 1000 >> LOAD 0x0000490000001000 0xffffc90000000000 0x0000000000000000 >> 0x00001fffffffffff 0x00001fffffffffff RWE 1000 >> LOAD 0x00007fffa0001000 0xffffffffa0000000 0x0000000000000000 >> 0x000000005f000000 0x000000005f000000 RWE 1000 >> ... >> >> >> So the way using /proc/iomem seems inappropriate, we have to consider other >> approaches (but I still don't have any good ideas...) > >Hello Atsushi, > >Hmmm ok, sure. For x86 using /proc/iomem does not work because there is no 1:1 >mapping for the kernel address space. The kernel/real memory is mapped somewhere >at the end, right? Exactly. >For s390 we have a 1:1 mapping for the kernel physical memory that starts with >zero. Therefore IMHO we could use /proc/iomem. For example, on my s390x system >with 1GB memory and 256MB crashkernel: > >$ cat /proc/iomem >00000000-2fffffff : System RAM > 00000000-007ddd4b : Kernel code > 007ddd4c-00bfcc5f : Kernel data > 00e18000-01c28b1f : Kernel bss >30000000-3fffffff : Crash kernel > >$ objdump -h /proc/kcore >... > Type Offset VirtAddr PhysAddr > FileSiz MemSiz Flags Align > NOTE 0x0000000000000158 0x0000000000000000 0x0000000000000000 > 0x00000000000027fc 0x0000000000000000 0 > LOAD 0x000003e080003000 0x000003e080000000 0x0000000000000000 > 0x0000001f00000000 0x0000001f00000000 RWE 1000 > LOAD 0x000003ff80003000 0x000003ff80000000 0x0000000000000000 > 0x0000000080000000 0x0000000080000000 RWE 1000 > LOAD 0x0000000000003000 0x0000000000000000 0x0000000000000000 > 0x0000000030000000 0x0000000030000000 RWE 1000 > LOAD 0x000003d100003000 0x000003d100000000 0x0000000000000000 > 0x0000000000c00000 0x0000000000c00000 RWE 1000 > >So in that case every /proc/kcore load that is below 0x30000000 must >be real memory. > >Michael I understand why your patch works on s390x, so how about this way ? 1. Define "is_phys_addr()" for --mem-usage. 2. Implement is_phys_addr() using is_iomem_phys_addr() for s390x while x86_64 uses is_vmalloc_addr_x86_64(). 3. Use is_phys_addr() instead of is_vmalloc_addr() in get_kcore_dump_loads(). Thanks, Atsushi Kumagai