Skip to contentSkip to conversation

mm: kill one if in loop of __free_pages_bootmem

PATCH In review Yinghai Lu 2 participants 2 messages Jul 23, 2013

Subsystems (2)
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 mm: kill one if in loop of __free_pages_bootmem

We should not check loop+1 with loop end in loop body. Just duplicate two lines code to avoid it.

That will help a bit when we have huge amount of pages on system with 16TiB memory.

---
 mm/page_alloc.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
mm/page_alloc.c +7 -7
Index: linux-2.6/mm/page_alloc.c
===================================================================
@@ -750,19 +750,19 @@ static void __free_pages_ok(struct page
 void __init __free_pages_bootmem(struct page *page, unsigned int order)
 {
 	unsigned int nr_pages = 1 << order;
+	struct page *p = page;
 	unsigned int loop;
 
-	prefetchw(page);
-	for (loop = 0; loop < nr_pages; loop++) {
-		struct page *p = &page[loop];
-
-		if (loop + 1 < nr_pages)
-			prefetchw(p + 1);
+	prefetchw(p);
+	for (loop = 0; loop < (nr_pages - 1); loop++, p++) {
+		prefetchw(p + 1);
 		__ClearPageReserved(p);
 		set_page_count(p, 0);
 	}
+	__ClearPageReserved(p);
+	set_page_count(p, 0);
 
-	page_zone(page)->managed_pages += 1 << order;
+	page_zone(page)->managed_pages += nr_pages;
 	set_page_refcounted(page);
 	__free_pages(page, order);
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Yinghai Lu

We should not check loop+1 with loop end in loop body. Just duplicate two lines code to avoid it.

That will help a bit when we have huge amount of pages on system with 16TiB memory.

Disassembly looks good, thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>