lkml.org 
[lkml]   [2004]   [Apr]   [16]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateFri, 16 Apr 2004 14:37:26 +1000
FromDavid Gibson <>
SubjectRe: Fix bogus get_page() calls in hugepage code
On Thu, Apr 15, 2004 at 09:30:11PM -0700, Andrew Morton wrote:
> David Gibson <david@gibson.dropbear.id.au> wrote:
> >
> > On some archs the functions used to implement follow_page() for
> >  hugepages do a get_page().  This is unlike the normal-page path for
> >  follow_page(), so presumably a bug.  This patch fixes it.
> 
> get_user_pages() is supposed to pin the pages which it placed into the
> callers pages[] array.
> 
> And the caller of get_user_pages() is supposed to unpin those pages when
> they are finished with.
> 
> So follow_hugetlb_page() is currently doing the right thing.  The asymmetry
> with follow_page() is awkward, but the overall intent was to minimise the
> amount of impact which the hugepage code has on core MM.

Yes, but I'm not talking about follow_hugetlb_page() (my patch doesn't
touch it).  I'm talking about follow_huge_addr() and
follow_huge_pmd().  These are called to implement follow_page().  In
get_user_pages(), follow_pages() is bypassed bu the call to
follow_hugetlb_page(), but these extra get_pages() are presumably a
bug if follow_page() is called on a hugepage from somewhere other than
get_user_pages().

So I think my patch is correct.

> Aside: note that get_user_pages() doesn't hold page_table_lock while
> walking the pagetables, whereas it does hold that lock while walking the
> regular pages' pagetables.  This is because the caller of get_user_pages()
> holds down_read(mmap_sem), whereas hugetlb pagetable setup and teardown
> always happens under down_write(mmap_sem).

Ah, that's useful to know.

-- 
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 13:02    [from the cache]
©2003-2008