• David Gibson's avatar
    [PATCH] hugepage: Small fixes to hugepage clear/copy path · 79ac6ba4
    David Gibson authored
    Move the loops used in mm/hugetlb.c to clear and copy hugepages to their
    own functions for clarity.  As we do so, we add some checks of need_resched
    - we are, after all copying megabytes of memory here.  We also add
    might_sleep() accordingly.  We generally dropped locks around the clear and
    copy, already but not everyone has PREEMPT enabled, so we should still be
    checking explicitly.
    
    For this to work, we need to remove the clear_huge_page() from
    alloc_huge_page(), which is called with the page_table_lock held in the COW
    path.  We move the clear_huge_page() to just after the alloc_huge_page() in
    the hugepage no-page path.  In the COW path, the new page is about to be
    copied over, so clearing it was just a waste of time anyway.  So as a side
    effect we also fix the fact that we held the page_table_lock for far too
    long in this path by calling alloc_huge_page() under it.
    
    It causes no regressions on the libhugetlbfs testsuite (ppc64, POWER5).
    Signed-off-by: default avatarDavid Gibson <dwg@au1.ibm.com>
    Cc: William Lee Irwin III <wli@holomorphy.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    79ac6ba4
hugetlb.c 14 KB