Skip to content

Commit

Permalink
mm: memory-failure: fetch compound head after extra page refcnt is held
Browse files Browse the repository at this point in the history
Page might become thp, huge page or being splited after compound head is
fetched but before page refcnt is bumped.  So hpage might be a tail page
leading to VM_BUG_ON_PAGE(PageTail(page)) in PageTransHuge().

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 415c64c ("mm/memory-failure: split thp earlier in memory error handling")
Signed-off-by: Miaohe Lin <[email protected]>
Acked-by: Naoya Horiguchi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
MiaoheLin authored and akpm00 committed Aug 18, 2023
1 parent 5885c6a commit a363d12
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -2175,8 +2175,6 @@ int memory_failure(unsigned long pfn, int flags)
goto unlock_mutex;
}

hpage = compound_head(p);

/*
* We need/can do nothing about count=0 pages.
* 1) it's a free page, and therefore in safe hand:
Expand Down Expand Up @@ -2215,6 +2213,7 @@ int memory_failure(unsigned long pfn, int flags)
}
}

hpage = compound_head(p);
if (PageTransHuge(hpage)) {
/*
* The flag must be set after the refcount is bumped
Expand Down

0 comments on commit a363d12

Please sign in to comment.