From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
dhowells@redhat.com, hch@infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] Making compound pages mandatory
Date: Wed, 17 Nov 2004 14:37:39 +1100 [thread overview]
Message-ID: <419AC783.5040909@yahoo.com.au> (raw)
In-Reply-To: <419AC3E7.9010904@yahoo.com.au>
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
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.
[-- Attachment #2: mm-less-ifdefs.patch --]
[-- Type: text/x-patch, Size: 2391 bytes --]
---
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
/*
_
next prev parent reply other threads:[~2004-11-17 3:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-16 18:48 [RFC] Making compound pages mandatory David Howells
2004-11-16 19:20 ` Andrew Morton
2004-11-16 19:41 ` David Howells
2004-11-17 1:50 ` Linus Torvalds
2004-11-17 2:28 ` Andrew Morton
2004-11-17 3:13 ` Nick Piggin
2004-11-17 3:22 ` Nick Piggin
2004-11-17 3:37 ` Nick Piggin [this message]
2004-11-17 3:42 ` Nick Piggin
2004-11-17 3:14 ` Linus Torvalds
2004-11-17 12:03 ` David Howells
2004-11-17 11:47 ` David Howells
2004-11-17 11:43 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=419AC783.5040909@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox