makedumpfile: clear mem_map if not in pt_loads
Subsystems (2)
PATCH 1/1 makedumpfile: clear mem_map if not in pt_loads
The crashed kernel passes usable RAM info through pt_loads[], but the current code ignore this, and parse all sections below info->max_mapnr. Refer to code in get_mm_sparsemem()
num_section = divideup(info->max_mapnr, PAGES_PER_SECTION());
These ranges can include unwanted memory e.g. reserved-memory for crash kernel, PMEM for fs-dax. Excluding them by setting mem_maps[section_nr]=NULL.
--- elf_info.c | 12 ++++++++++++ elf_info.h | 1 + makedumpfile.c | 5 +++++ 3 files changed, 18 insertions(+)
elf_info.c +12 -0
@@ -1302,3 +1302,15 @@ get_max_file_offset(void) {return max_file_offset; } + +int phyaddr_in_pt_loads (unsigned long long phys_start) +{ +struct pt_load_segment *pls; + +for (int i =0 ; i < num_pt_loads; i++) { + pls = &pt_loads[i]; +if (phys_start >= pls->phys_start && phys_start < pls->phys_end) +return TRUE; + } +return FALSE; +}
elf_info.h +1 -0
@@ -90,6 +90,7 @@ void get_eraseinfo(off_t *offset, unsigned long *size);void set_eraseinfo (off_t offset,unsigned long size);off_t get_max_file_offset (void ); +int phyaddr_in_pt_loads (unsigned long long phys_start);#endif /* ELF_INFO_H */
makedumpfile.c +5 -0
@@ -3556,8 +3556,13 @@ get_mm_sparsemem(void) goto out; }for (section_nr =0 ; section_nr < num_section; section_nr++) { +unsigned long phys_start; + pfn_start = section_nr *PAGES_PER_SECTION (); pfn_end = pfn_start +PAGES_PER_SECTION (); + phys_start = pfn_start <<PAGESHIFT (); +if (!phyaddr_in_pt_loads (phys_start)) + mem_maps[section_nr] = (unsigned long )NULL ;if (info->max_mapnr < pfn_end) pfn_end = info->max_mapnr;dump_mem_map (pfn_start, pfn_end, mem_maps[section_nr], section_nr);
Signature · 7 lines
2.7.5 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi Pingfan,
Quoted 8 lines
-----Original Message-----
The crashed kernel passes usable RAM info through pt_loads[], but the current code ignore this, and parse all sections belowinfo->max_mapnr. Refer to code inget_mm_sparsemem()
num_section=divideup(info->max_mapnr, PAGES_PER_SECTION());These ranges can include unwanted memory e.g. reserved-memory for crash kernel, PMEM for fs-dax. Excluding them by setting mem_maps[section_nr]=NULL.
hmm, I think that bitmap1 corresponds to pt_loads ranges, so even without the patch, only the ranges in pt_loads can be included in a dumpfile. Am I missing anything?
Thanks,
Kazu
Quoted 59 lines
Signed-off-by Pingfan Liu <[email protected]>--- elf_info.c | 12 ++++++++++++ elf_info.h | 1 + makedumpfile.c | 5 +++++ 3 files changed, 18 insertions(+)elf_info.c +12
-0@@ -1302,3 +1302,15 @@ get_max_file_offset(void) {return max_file_offset; } + +int phyaddr_in_pt_loads (unsigned long long phys_start) +{ +struct pt_load_segment *pls; + +for (int i =0 ; i < num_pt_loads; i++) { + pls = &pt_loads[i]; +if (phys_start >= pls->phys_start && phys_start < pls->phys_end) +return TRUE; + } +return FALSE; +}elf_info.h +1
-0@@ -90,6 +90,7 @@ void get_eraseinfo(off_t *offset, unsigned long *size);void set_eraseinfo (off_t offset,unsigned long size);off_t get_max_file_offset (void ); +int phyaddr_in_pt_loads (unsigned long long phys_start);#endif /* ELF_INFO_H */ makedumpfile.c +5
-1@@ -3556,8 +3556,13 @@ get_mm_sparsemem(void) goto out; }for (section_nr =0 ; section_nr < num_section; section_nr++) { +unsigned long phys_start; + pfn_start = section_nr *PAGES_PER_SECTION (); pfn_end = pfn_start +PAGES_PER_SECTION (); + phys_start = pfn_start <<PAGESHIFT (); +if (!phyaddr_in_pt_loads (phys_start)) + mem_maps[section_nr] = (unsigned long )NULL ;if (info->max_mapnr < pfn_end) pfn_end = info->max_mapnr;dump_mem_map (pfn_start, pfn_end, mem_maps[section_nr], section_nr); --
Quoted 1 line
2.7.5
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 8 lines · HAGIO KAZUHITO(萩尾 一仁)
Hi Pingfan,
Quoted 6 lines
-----Original Message-----
The crashed kernel passes usable RAM info through pt_loads[], but the current code ignore this, and parse all sections belowinfo->max_mapnr. Refer to code inget_mm_sparsemem()
num_section=divideup(info->max_mapnr, PAGES_PER_SECTION());
Quoted 7 lines
Quoted 2 lines
These ranges can include unwanted memory e.g. reserved-memory for crash kernel, PMEM for fs-dax. Excluding them by setting mem_maps[section_nr]=NULL.
hmm, I think that bitmap1 corresponds to
pt_loadsranges, so even without the patch, only the ranges inpt_loadscan be included in a dumpfile. Am I missing anything?
Check the code, and I think you are right.
Thanks,
Pingfan
Quoted 55 lines
Thanks,
KazuQuoted 52 lines
Signed-off-by Pingfan Liu <[email protected]>--- elf_info.c | 12 ++++++++++++ elf_info.h | 1 + makedumpfile.c | 5 +++++ 3 files changed, 18 insertions(+)elf_info.c +12
-0@@ -1302,3 +1302,15 @@ get_max_file_offset(void) {return max_file_offset; } + +int phyaddr_in_pt_loads (unsigned long long phys_start) +{ +struct pt_load_segment *pls; + +for (int i =0 ; i < num_pt_loads; i++) { + pls = &pt_loads[i]; +if (phys_start >= pls->phys_start && phys_start < pls->phys_end) +return TRUE; + } +return FALSE; +}elf_info.h +1
-0@@ -90,6 +90,7 @@ void get_eraseinfo(off_t *offset, unsigned long *size);void set_eraseinfo (off_t offset,unsigned long size);off_t get_max_file_offset (void ); +int phyaddr_in_pt_loads (unsigned long long phys_start);#endif /* ELF_INFO_H */ makedumpfile.c +2
-0@@ -3556,8 +3556,13 @@ get_mm_sparsemem(void) goto out; }for (section_nr =0 ; section_nr < num_section; section_nr++) { +unsigned long phys_start; + pfn_start = section_nr *PAGES_PER_SECTION (); pfn_end = pfn_start +PAGES_PER_SECTION ();
Quoted 9 lines
Quoted 8 lines
makedumpfile.c +3
-1+ phys_start = pfn_start <<PAGESHIFT (); +if (!phyaddr_in_pt_loads (phys_start)) + mem_maps[section_nr] = (unsigned long )NULL ;if (info->max_mapnr < pfn_end) pfn_end = info->max_mapnr;dump_mem_map (pfn_start, pfn_end, mem_maps[section_nr], section_nr); --2.7.5
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec