• Naoya Horiguchi's avatar
    mm/memory-failure: split thp earlier in memory error handling · da7cbd0c
    Naoya Horiguchi authored
    [ Upstream commit 415c64c1 ]
    
    memory_failure() doesn't handle thp itself at this time and need to split
    it before doing isolation.  Currently thp is split in the middle of
    hwpoison_user_mappings(), but there're corner cases where memory_failure()
    wrongly tries to handle thp without splitting.
    
    1) "non anonymous" thp, which is not a normal operating mode of thp,
       but a memory error could hit a thp before anon_vma is initialized.  In
       such case, split_huge_page() fails and me_huge_page() (intended for
       hugetlb) is called for thp, which triggers BUG_ON in page_hstate().
    
    2) !PageLRU case, where hwpoison_user_mappings() returns with
       SWAP_SUCCESS and the result is the same as case 1.
    
    memory_failure() can't avoid splitting, so let's split it more earlier,
    which also reduces code which are prepared for both of normal page and
    thp.
    Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Cc: Andi Kleen <andi@firstfloor.org>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
    da7cbd0c
memory-failure.c 47.3 KB