• Yang Shi's avatar
    mm: migrate: simplify the logic for handling permanent failure · dd4ae78a
    Yang Shi authored
    When unmap_and_move{_huge_page}() returns !-EAGAIN and
    !MIGRATEPAGE_SUCCESS, the page would be put back to LRU or proper list if
    it is non-LRU movable page.  But, the callers always call
    putback_movable_pages() to put the failed pages back later on, so it seems
    not very efficient to put every single page back immediately, and the code
    looks convoluted.
    
    Put the failed page on a separate list, then splice the list to migrate
    list when all pages are tried.  It is the caller's responsibility to call
    putback_movable_pages() to handle failures.  This also makes the code
    simpler and more readable.
    
    After the change the rules are:
        * Success: non hugetlb page will be freed, hugetlb page will be put
                   back
        * -EAGAIN: stay on the from list
        * -ENOMEM: stay on the from list
        * Other errno: put on ret_pages list then splice to from list
    
    The from list would be empty iff all pages are migrated successfully, it
    was not so before.  This has no impact to current existing callsites.
    
    Link: https://lkml.kernel.org/r/20201113205359.556831-3-shy828301@gmail.comSigned-off-by: default avatarYang Shi <shy828301@gmail.com>
    Reviewed-by: default avatarZi Yan <ziy@nvidia.com>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Song Liu <songliubraving@fb.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    dd4ae78a
migrate.c 81.2 KB