From: Dave Hansen While super-nifty, the new page_owner code assumes a contiguous mem_map, which we don't all have. This patch changes the iterator in the read_page_owner() to be a pfn instead of a 'struct page'. This makes it easy to jump around to different non-contiuous 'struct pages' as with the CONFIG_DISCONTIG code. It also uses pfn_valid() instead of max_pfn, which seems to be a bit more flexible, and handles holes where there are no 'struct pages' on the DISCONTIG systems. BTW, I have no idea why that loop ended with a continue; Signed-off-by: Dave Hansen Signed-off-by: Andrew Morton --- 25-akpm/fs/proc/proc_misc.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff -puN fs/proc/proc_misc.c~make-page_owner-handle-non-contiguous-page-ranges fs/proc/proc_misc.c --- 25/fs/proc/proc_misc.c~make-page_owner-handle-non-contiguous-page-ranges Thu Feb 3 15:08:39 2005 +++ 25-akpm/fs/proc/proc_misc.c Thu Feb 3 15:08:39 2005 @@ -540,8 +540,9 @@ static struct file_operations proc_sysrq static ssize_t read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - struct page *start = pfn_to_page(min_low_pfn); - static struct page *page; + unsigned long start_pfn = min_low_pfn; + static unsigned long pfn; + struct page *page; char *kbuf, *modname; const char *symname; int ret = 0, next_idx = 1; @@ -549,15 +550,18 @@ read_page_owner(struct file *file, char unsigned long offset = 0, symsize; int i; - page = start + *ppos; - for (; page < pfn_to_page(max_pfn); page++) { + pfn = start_pfn + *ppos; + page = pfn_to_page(pfn); + for (; pfn < max_pfn; pfn++) { + if (!pfn_valid(pfn)) + continue; + page = pfn_to_page(pfn); if (page->order >= 0) break; next_idx++; - continue; } - if (page >= pfn_to_page(max_pfn)) + if (!pfn_valid(pfn)) return 0; *ppos += next_idx; _