Skip to content

Commit

Permalink
hwpoison: fix race with changing page during offlining
Browse files Browse the repository at this point in the history
When a hwpoison page is locked it could change state due to parallel
modifications.  The original compound page can be torn down and then
this 4k page becomes part of a differently-size compound page is is a
standalone regular page.

Check after the lock if the page is still the same compound page.

We could go back, grab the new head page and try again but it should be
quite rare, so I thought this was safest.  A retry loop would be more
difficult to test and may have more side effects.

The hwpoison code by design only tries to handle cases that are
reasonably common in workloads, as visible in page-flags.

I'm not really that concerned about handling this (likely rare case),
just not crashing on it.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Aug 7, 2014
1 parent ad4404a commit f37d429
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,16 @@ int memory_failure(unsigned long pfn, int trapno, int flags)

lock_page(hpage);

/*
* The page could have changed compound pages during the locking.
* If this happens just bail out.
*/
if (compound_head(p) != hpage) {
action_result(pfn, "different compound page after locking", IGNORED);
res = -EBUSY;
goto out;
}

/*
* We use page flags to determine what action should be taken, but
* the flags can be modified by the error containment action. One
Expand Down

0 comments on commit f37d429

Please sign in to comment.