aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mm.h
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-05-06 17:49:39 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:53 -0400
commitd85f33855c303acfa87fa457157cef755b6087df (patch)
treef1184a1a24b432727b0399594ede37c7539db888 /include/linux/mm.h
parent30520864839dc796fd314812e7036e754880b47d (diff)
Make page->private usable in compound pages
If we add a new flag so that we can distinguish between the first page and the tail pages then we can avoid to use page->private in the first page. page->private == page for the first page, so there is no real information in there. Freeing up page->private makes the use of compound pages more transparent. They become more usable like real pages. Right now we have to be careful f.e. if we are going beyond PAGE_SIZE allocations in the slab on i386 because we can then no longer use the private field. This is one of the issues that cause us not to support debugging for page size slabs in SLAB. Having page->private available for SLUB would allow more meta information in the page struct. I can probably avoid the 16 bit ints that I have in there right now. Also if page->private is available then a compound page may be equipped with buffer heads. This may free up the way for filesystems to support larger blocks than page size. We add PageTail as an alias of PageReclaim. Compound pages cannot currently be reclaimed. Because of the alias one needs to check PageCompound first. The RFC for the this approach was discussed at http://marc.info/?t=117574302800001&r=1&w=2 [nacc@us.ibm.com: fix hugetlbfs] Signed-off-by: Christoph Lameter <clameter@sgi.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> 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.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c95d96ebd5ad..8c149fa4491d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -267,17 +267,28 @@ static inline int get_page_unless_zero(struct page *page)
267 return atomic_inc_not_zero(&page->_count); 267 return atomic_inc_not_zero(&page->_count);
268} 268}
269 269
270static inline struct page *compound_head(struct page *page)
271{
272 /*
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;
281 return page;
282}
283
270static inline int page_count(struct page *page) 284static inline int page_count(struct page *page)
271{ 285{
272 if (unlikely(PageCompound(page))) 286 return atomic_read(&compound_head(page)->_count);
273 page = (struct page *)page_private(page);
274 return atomic_read(&page->_count);
275} 287}
276 288
277static inline void get_page(struct page *page) 289static inline void get_page(struct page *page)
278{ 290{
279 if (unlikely(PageCompound(page))) 291 page = compound_head(page);
280 page = (struct page *)page_private(page);
281 VM_BUG_ON(atomic_read(&page->_count) == 0); 292 VM_BUG_ON(atomic_read(&page->_count) == 0);
282 atomic_inc(&page->_count); 293 atomic_inc(&page->_count);
283} 294}
@@ -314,6 +325,18 @@ static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
314 return (compound_page_dtor *)page[1].lru.next; 325 return (compound_page_dtor *)page[1].lru.next;
315} 326}
316 327
328static inline int compound_order(struct page *page)
329{
330 if (!PageCompound(page) || PageTail(page))
331 return 0;
332 return (unsigned long)page[1].lru.prev;
333}
334
335static inline void set_compound_order(struct page *page, unsigned long order)
336{
337 page[1].lru.prev = (void *)order;
338}
339
317/* 340/*
318 * Multiple processes may "see" the same page. E.g. for untouched 341 * Multiple processes may "see" the same page. E.g. for untouched
319 * mappings of /dev/null, all processes see the same page full of 342 * mappings of /dev/null, all processes see the same page full of