• Yang Shi's avatar
    mm: thp: refactor NUMA fault handling · c5b5a3dd
    Yang Shi authored
    When the THP NUMA fault support was added THP migration was not supported
    yet.  So the ad hoc THP migration was implemented in NUMA fault handling.
    Since v4.14 THP migration has been supported so it doesn't make too much
    sense to still keep another THP migration implementation rather than using
    the generic migration code.
    
    This patch reworks the NUMA fault handling to use generic migration
    implementation to migrate misplaced page.  There is no functional change.
    
    After the refactor the flow of NUMA fault handling looks just like its
    PTE counterpart:
      Acquire ptl
      Prepare for migration (elevate page refcount)
      Release ptl
      Isolate page from lru and elevate page refcount
      Migrate the misplaced THP
    
    If migration fails just restore the old normal PMD.
    
    In the old code anon_vma lock was needed to serialize THP migration
    against THP split, but since then the THP code has been reworked a lot, it
    seems anon_vma lock is not required anymore to avoid the race.
    
    The page refcount elevation when holding ptl should prevent from THP
    split.
    
    Use migrate_misplaced_page() for both base page and THP NUMA hinting fault
    and remove all the dead and duplicate code.
    
    [dan.carpenter@oracle.com: fix a double unlock bug]
      Link: https://lkml.kernel.org/r/YLX8uYN01JmfLnlK@mwanda
    
    Link: https://lkml.kernel.org/r/20210518200801.7413-4-shy828301@gmail.comSigned-off-by: default avatarYang Shi <shy828301@gmail.com>
    Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
    Acked-by: default avatarMel Gorman <mgorman@suse.de>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Huang Ying <ying.huang@intel.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    c5b5a3dd
migrate.c 78 KB