• Mel Gorman's avatar
    mm: Close races between THP migration and PMD numa clearing · 3f926ab9
    Mel Gorman authored
    THP migration uses the page lock to guard against parallel allocations
    but there are cases like this still open
    
      Task A					Task B
      ---------------------				---------------------
      do_huge_pmd_numa_page				do_huge_pmd_numa_page
      lock_page
      mpol_misplaced == -1
      unlock_page
      goto clear_pmdnuma
    						lock_page
    						mpol_misplaced == 2
    						migrate_misplaced_transhuge
      pmd = pmd_mknonnuma
      set_pmd_at
    
    During hours of testing, one crashed with weird errors and while I have
    no direct evidence, I suspect something like the race above happened.
    This patch extends the page lock to being held until the pmd_numa is
    cleared to prevent migration starting in parallel while the pmd_numa is
    being cleared. It also flushes the old pmd entry and orders pagetable
    insertion before rmap insertion.
    Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
    Reviewed-by: default avatarRik van Riel <riel@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Cc: <stable@kernel.org>
    Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1381141781-10992-9-git-send-email-mgorman@suse.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    3f926ab9
huge_memory.c 74.3 KB