Skip to content

Commit

Permalink
ARM: 6093/1: Fix kernel memory printing for sparsemem
Browse files Browse the repository at this point in the history
The show_mem() and mem_init() function are assuming that the page map is
contiguous and calculates the start and end page of a bank using (map +
pfn). This fails with SPARSEMEM where pfn_to_page() must be used.

Tested-by: Will Deacon <Will.Deacon@arm.com>
Tested-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Catalin Marinas authored and Russell King committed May 4, 2010
1 parent ab92e74 commit ea056df
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions arch/arm/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ void show_mem(void)
printk("Mem-info:\n");
show_free_areas();
for_each_online_node(node) {
pg_data_t *n = NODE_DATA(node);
struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn;

for_each_nodebank (i,mi,node) {
struct membank *bank = &mi->bank[i];
unsigned int pfn1, pfn2;
Expand All @@ -97,8 +94,8 @@ void show_mem(void)
pfn1 = bank_pfn_start(bank);
pfn2 = bank_pfn_end(bank);

page = map + pfn1;
end = map + pfn2;
page = pfn_to_page(pfn1);
end = pfn_to_page(pfn2 - 1) + 1;

do {
total++;
Expand Down Expand Up @@ -603,9 +600,6 @@ void __init mem_init(void)
reserved_pages = free_pages = 0;

for_each_online_node(node) {
pg_data_t *n = NODE_DATA(node);
struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn;

for_each_nodebank(i, &meminfo, node) {
struct membank *bank = &meminfo.bank[i];
unsigned int pfn1, pfn2;
Expand All @@ -614,8 +608,8 @@ void __init mem_init(void)
pfn1 = bank_pfn_start(bank);
pfn2 = bank_pfn_end(bank);

page = map + pfn1;
end = map + pfn2;
page = pfn_to_page(pfn1);
end = pfn_to_page(pfn2 - 1) + 1;

do {
if (PageReserved(page))
Expand Down

0 comments on commit ea056df

Please sign in to comment.