• Andy Whitcroft's avatar
    hugetlbfs: allocate structures for reservation tracking outside of spinlocks · 57303d80
    Andy Whitcroft authored
    In the normal case, hugetlbfs reserves hugepages at map time so that the
    pages exist for future faults.  A struct file_region is used to track when
    reservations have been consumed and where.  These file_regions are
    allocated as necessary with kmalloc() which can sleep with the
    mm->page_table_lock held.  This is wrong and triggers may-sleep warning
    when PREEMPT is enabled.
    Updates to the underlying file_region are done in two phases.  The first
    phase prepares the region for the change, allocating any necessary memory,
    without actually making the change.  The second phase actually commits the
    change.  This patch makes use of this by checking the reservations before
    the page_table_lock is taken; triggering any necessary allocations.  This
    may then be safely repeated within the locks without any allocations being
    Credit to Mel Gorman for diagnosing this failure and initial versions of
    the patch.
    Signed-off-by: default avatarAndy Whitcroft <apw@shadowen.org>
    Tested-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
    Cc: Mel Gorman <mel@csn.ul.ie>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>