aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mm.h
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 /include/linux/mm.h
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 'include/linux/mm.h')
-rw-r--r--include/linux/mm.h11
1 files changed, 2 insertions, 9 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 8c149fa4491d..695b90437bbc 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -269,14 +269,7 @@ static inline int get_page_unless_zero(struct page *page)
269 269
270static inline struct page *compound_head(struct page *page) 270static inline struct page *compound_head(struct page *page)
271{ 271{
272 /* 272 if (unlikely(PageTail(page)))
273 * We could avoid the PageCompound(page) check if
274 * we would not overload PageTail().
275 *
276 * This check has to be done in several performance critical
277 * paths of the slab etc. IMHO PageTail deserves its own flag.
278 */
279 if (unlikely(PageCompound(page) && PageTail(page)))
280 return page->first_page; 273 return page->first_page;
281 return page; 274 return page;
282} 275}
@@ -327,7 +320,7 @@ static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
327 320
328static inline int compound_order(struct page *page) 321static inline int compound_order(struct page *page)
329{ 322{
330 if (!PageCompound(page) || PageTail(page)) 323 if (!PageHead(page))
331 return 0; 324 return 0;
332 return (unsigned long)page[1].lru.prev; 325 return (unsigned long)page[1].lru.prev;
333} 326}