lkml.org 
[lkml]   [2004]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: put_page() tries to handle hugepages but fails
On Mon, Apr 26, 2004 at 09:47:57PM -0700, Andrew Morton wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> >
> > + if (put_page_testzero(page))
> > + free_huge_page(page);
>
> Well yes, but this is assuming that compound pages are always hugetlb pages.
>
> It's true at present, but it doesn't have to always be true. The cost of
> the destructor is zilch, so why not?

True enough, I guess I was just following the "don't build it till you
need it" philosophy.

> Please review the changes which went into 2.6.6-rc2-mm2.

Sorry, should have done that earlier. Looks reasonable with two small
exceptions: 1) put_page() can still theoretically call
__page_cache_release() which is wrong (and makes the code misleading)
- patch below replaces this with a BUG() if there is no destructor. 2)
what about wli's concern that mapping may be accessed without first
checking for a PageCompound?

Index: working-2.6/mm/swap.c
===================================================================
--- working-2.6.orig/mm/swap.c 2004-04-14 12:22:49.000000000 +1000
+++ working-2.6/mm/swap.c 2004-04-27 15:02:30.046342392 +1000
@@ -41,11 +41,9 @@
if (unlikely(PageCompound(page))) {
page = (struct page *)page->private;
if (put_page_testzero(page)) {
- if (page[1].mapping) { /* destructor? */
- (*(void (*)(struct page *))page[1].mapping)(page);
- } else {
- __page_cache_release(page);
- }
+ BUG_ON(! page[1].mapping);
+
+ (*(void (*)(struct page *))page[1].mapping)(page);
}
return;
}

--
David Gibson | For every complex problem there is a
david AT gibson.dropbear.id.au | solution which is simple, neat and
| wrong.
http://www.ozlabs.org/people/dgibson
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:02    [W:0.071 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site