[PATCH] use pfn_to_page in show_mem

From: Wang Nan
Date: Thu Jan 02 2014 - 00:20:02 EST


If a bank spans into different sections, the page structures of the bank
may not continous.

This patch uses pfn_to_page to recompute the address of struct page in show_mem
from pfn, makes it to collect correct information even if a bank spans into
different sections.

Signed-off-by: Wang Nan <wangnan0@xxxxxxxxxx>
---
arch/arm/mm/init.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 1f7b19a..3078e5a 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -97,16 +97,14 @@ void show_mem(unsigned int filter)

for_each_bank (i, mi) {
struct membank *bank = &mi->bank[i];
- unsigned int pfn1, pfn2;
- struct page *page, *end;
+ unsigned int pfn, pfn_end;
+ struct page *page;

- pfn1 = bank_pfn_start(bank);
- pfn2 = bank_pfn_end(bank);
-
- page = pfn_to_page(pfn1);
- end = pfn_to_page(pfn2 - 1) + 1;
+ pfn = bank_pfn_start(bank);
+ pfn_end = bank_pfn_end(bank);

do {
+ page = pfn_to_page(pfn);
total++;
if (PageReserved(page))
reserved++;
@@ -118,8 +116,8 @@ void show_mem(unsigned int filter)
free++;
else
shared += page_count(page) - 1;
- page++;
- } while (page < end);
+ pfn++;
+ } while (pfn < pfn_end);
}

printk("%d pages of RAM\n", total);
--
1.8.4





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/