Messages in this thread Patch in this message | | | Date | Wed, 17 Nov 2004 14:37:39 +1100 | From | Nick Piggin <> | Subject | Re: [RFC] Making compound pages mandatory |
| |
Nick Piggin wrote: > Nick Piggin wrote: > >> >> Good idea. BTW, any reason why the following (very)micro optimisation >> shouldn't go in? >> >> It currently only picks up a couple of things under fs/, but might help >> reduce other ifdefery around the place. For example mm.h: page_count and >> get_page. >> > > Like this, perhaps? It does actually introduce a change in the object > code. Namely hugetlb's put_page will now also be done inline for non > compound pages - maybe this change is unacceptable though, but it does > cut down the ifdefs.
Err... attached.
---
linux-2.6-npiggin/include/linux/mm.h | 20 ++++---------------- linux-2.6-npiggin/mm/swap.c | 20 +++++++------------- 2 files changed, 11 insertions(+), 29 deletions(-)
diff -puN include/linux/mm.h~mm-less-ifdefs include/linux/mm.h --- linux-2.6/include/linux/mm.h~mm-less-ifdefs 2004-11-17 14:14:12.000000000 +1100 +++ linux-2.6-npiggin/include/linux/mm.h 2004-11-17 14:17:24.000000000 +1100 @@ -288,11 +288,9 @@ struct page { extern void FASTCALL(__page_cache_release(struct page *)); -#ifdef CONFIG_HUGETLB_PAGE - static inline int page_count(struct page *p) { - if (PageCompound(p)) + if (unlikely(PageCompound(p))) p = (struct page *)p->private; return atomic_read(&(p)->_count) + 1; } @@ -304,25 +302,15 @@ static inline void get_page(struct page atomic_inc(&page->_count); } -void put_page(struct page *page); - -#else /* CONFIG_HUGETLB_PAGE */ - -#define page_count(p) (atomic_read(&(p)->_count) + 1) - -static inline void get_page(struct page *page) -{ - atomic_inc(&page->_count); -} - +void put_compound_page(struct page *page); static inline void put_page(struct page *page) { + if (unlikely(PageCompound(page))) + put_compound_page(page); if (!PageReserved(page) && put_page_testzero(page)) __page_cache_release(page); } -#endif /* CONFIG_HUGETLB_PAGE */ - /* * Multiple processes may "see" the same page. E.g. for untouched * mappings of /dev/null, all processes see the same page full of diff -puN mm/swap.c~mm-less-ifdefs mm/swap.c --- linux-2.6/mm/swap.c~mm-less-ifdefs 2004-11-17 14:15:20.000000000 +1100 +++ linux-2.6-npiggin/mm/swap.c 2004-11-17 14:15:48.000000000 +1100 @@ -35,23 +35,17 @@ int page_cluster; #ifdef CONFIG_HUGETLB_PAGE - -void put_page(struct page *page) +void put_compound_page(struct page *page) { - if (unlikely(PageCompound(page))) { - page = (struct page *)page->private; - if (put_page_testzero(page)) { - void (*dtor)(struct page *page); + page = (struct page *)page->private; + if (put_page_testzero(page)) { + void (*dtor)(struct page *page); - dtor = (void (*)(struct page *))page[1].mapping; - (*dtor)(page); - } - return; + dtor = (void (*)(struct page *))page[1].mapping; + (*dtor)(page); } - if (!PageReserved(page) && put_page_testzero(page)) - __page_cache_release(page); } -EXPORT_SYMBOL(put_page); +EXPORT_SYMBOL(put_compound_page); #endif /* _
| |