aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-05-06 17:49:40 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:53 -0400
commit6d7779538f765963ced45a3fa4bed7ba8d2c277d (patch)
tree07d47e6ff1ab30309004e2ba0674dcabd83945c1 /mm
parentd85f33855c303acfa87fa457157cef755b6087df (diff)
mm: optimize compound_head() by avoiding a shared page flag
The patch adds PageTail(page) and PageHead(page) to check if a page is the head or the tail of a compound page. This is done by masking the two bits describing the state of a compound page and then comparing them. So one comparision and a branch instead of two bit checks and two branches. Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fc241fe295ab..36d713e216e8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -235,12 +235,11 @@ static void prep_compound_page(struct page *page, unsigned long order)
235 235
236 set_compound_page_dtor(page, free_compound_page); 236 set_compound_page_dtor(page, free_compound_page);
237 set_compound_order(page, order); 237 set_compound_order(page, order);
238 __SetPageCompound(page); 238 __SetPageHead(page);
239 for (i = 1; i < nr_pages; i++) { 239 for (i = 1; i < nr_pages; i++) {
240 struct page *p = page + i; 240 struct page *p = page + i;
241 241
242 __SetPageTail(p); 242 __SetPageTail(p);
243 __SetPageCompound(p);
244 p->first_page = page; 243 p->first_page = page;
245 } 244 }
246} 245}
@@ -253,17 +252,16 @@ static void destroy_compound_page(struct page *page, unsigned long order)
253 if (unlikely(compound_order(page) != order)) 252 if (unlikely(compound_order(page) != order))
254 bad_page(page); 253 bad_page(page);
255 254
256 if (unlikely(!PageCompound(page))) 255 if (unlikely(!PageHead(page)))
257 bad_page(page); 256 bad_page(page);
258 __ClearPageCompound(page); 257 __ClearPageHead(page);
259 for (i = 1; i < nr_pages; i++) { 258 for (i = 1; i < nr_pages; i++) {
260 struct page *p = page + i; 259 struct page *p = page + i;
261 260
262 if (unlikely(!PageCompound(p) | !PageTail(p) | 261 if (unlikely(!PageTail(p) |
263 (p->first_page != page))) 262 (p->first_page != page)))
264 bad_page(page); 263 bad_page(page);
265 __ClearPageTail(p); 264 __ClearPageTail(p);
266 __ClearPageCompound(p);
267 } 265 }
268} 266}
269 267