On Wed, 19 Mar 2014 07:14:25 +0000 Atsushi Kumagai <kumagai-atsushi at mxc.nes.nec.co.jp> wrote: > >Hello Atsushi, > > > >I debugged my problem a bit further and tried to implement > >a function that gets the maximum page frame number from the > >Linux kernel memory management structures. > > > >I am no memory management expert, so the following patch probably > >is not complete, but at least for my setup it worked. > > The patch looks good for your case, but I don't think it's a proper > approach for this problem. Hello Atsushi, If you don't like that solution, what about using the mem_map_data[] array of makedumpfile to adjust "max_mapnr"? The patch below also works fine for my dump. Michael --- makedumpfile.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) --- a/makedumpfile.c +++ b/makedumpfile.c @@ -2829,7 +2829,8 @@ get_mem_map_without_mm(void) int get_mem_map(void) { - int ret; + unsigned long max_pfn = 0; + int ret, i; switch (get_mem_type()) { case SPARSEMEM: @@ -2861,6 +2862,17 @@ get_mem_map(void) ret = FALSE; break; } + /* + * Adjust "max_mapnr" for the case that Linux uses less memory + * than is dumped. For example when "mem=" has been used for the + * dumped system. + */ + for (i = 0; i < info->num_mem_map; i++) { + if (info->mem_map_data[i].mem_map == NOT_MEMMAP_ADDR) + continue; + max_pfn = MAX(max_pfn, info->mem_map_data[i].pfn_end); + } + info->max_mapnr = max_pfn; return ret; }