From: Alexander Nyberg <alexn@telia.com>

I've cleaned up the __alloc_pages() part to a simple set_page_owner() call.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 fs/proc/proc_misc.c |    5 ++---
 mm/page_alloc.c     |   33 +++++++++++++++++++--------------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff -puN fs/proc/proc_misc.c~page-owner-tracking-leak-detector-tidy fs/proc/proc_misc.c
--- devel/fs/proc/proc_misc.c~page-owner-tracking-leak-detector-tidy	2005-07-08 23:11:40.000000000 -0700
+++ devel-akpm/fs/proc/proc_misc.c	2005-07-08 23:11:40.000000000 -0700
@@ -559,8 +559,7 @@ static struct file_operations proc_sysrq
 static ssize_t
 read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-	unsigned long start_pfn = min_low_pfn;
-	static unsigned long pfn;
+	unsigned long pfn;
 	struct page *page;
 	char *kbuf, *modname;
 	const char *symname;
@@ -569,7 +568,7 @@ read_page_owner(struct file *file, char 
 	unsigned long offset = 0, symsize;
 	int i;
 
-	pfn = start_pfn + *ppos;
+	pfn = min_low_pfn + *ppos;
 	page = pfn_to_page(pfn);
 	for (; pfn < max_pfn; pfn++) {
 		if (!pfn_valid(pfn))
diff -puN mm/page_alloc.c~page-owner-tracking-leak-detector-tidy mm/page_alloc.c
--- devel/mm/page_alloc.c~page-owner-tracking-leak-detector-tidy	2005-07-08 23:11:40.000000000 -0700
+++ devel-akpm/mm/page_alloc.c	2005-07-08 23:11:40.000000000 -0700
@@ -776,7 +776,8 @@ static inline int valid_stack_ptr(struct
 		p < (void *)tinfo + THREAD_SIZE - 3;
 }
 
-static inline void __stack_trace(struct page *page, unsigned long *stack, unsigned long bp)
+static inline void __stack_trace(struct page *page, unsigned long *stack,
+			unsigned long bp)
 {
 	int i = 0;
 	unsigned long addr;
@@ -785,7 +786,7 @@ static inline void __stack_trace(struct 
 
 	memset(page->trace, 0, sizeof(long) * 8);
 
-#ifdef	CONFIG_FRAME_POINTER
+#ifdef CONFIG_FRAME_POINTER
 	while (valid_stack_ptr(tinfo, (void *)bp)) {
 		addr = *(unsigned long *)(bp + sizeof(long));
 		page->trace[i] = addr;
@@ -804,6 +805,20 @@ static inline void __stack_trace(struct 
 	}
 #endif
 }
+
+static inline void set_page_owner(struct page *page,
+			unsigned int order, unsigned int gfp_mask)
+{
+	unsigned long address, bp;
+#ifdef X86_64
+	asm ("movq %%rbp, %0" : "=r" (bp) : );
+#else
+	asm ("movl %%ebp, %0" : "=r" (bp) : );
+#endif
+	page->order = (int) order;
+	page->gfp_mask = gfp_mask;
+	__stack_trace(page, &address, bp);
+}
 #endif /* CONFIG_PAGE_OWNER */
 
 /*
@@ -1001,19 +1016,9 @@ nopage:
 	return NULL;
 got_pg:
 
-#ifdef CONFIG_PAGE_OWNER /* huga... */
-	{
-	unsigned long address, bp;
-#ifdef X86_64
-	asm ("movq %%rbp, %0" : "=r" (bp) : );
-#else
-	asm ("movl %%ebp, %0" : "=r" (bp) : );
+#ifdef CONFIG_PAGE_OWNER
+	set_page_owner(page, order, gfp_mask);
 #endif
-	page->order = (int) order;
-	page->gfp_mask = gfp_mask;
-	__stack_trace(page, &address, bp);
-	}
-#endif /* CONFIG_PAGE_OWNER */
 	zone_statistics(zonelist, z);
 	return page;
 }
_