diff options
author | Andi Kleen <ak@linux.intel.com> | 2014-07-17 10:57:59 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2014-07-17 10:57:59 +1000 |
commit | 713f528207c6265fe42cc7a387d250f7d8f82d16 (patch) | |
tree | ee62ec18b0d76b1614680188606e2eff92123b66 /mm | |
parent | f44db76bfb6080624c46e2128dd8590f86202929 (diff) |
hwpoison: fix race with changing page during offlining
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memory-failure.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7211a73ba14d..e3e2f007946e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1165,6 +1165,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 * example is an mlocked page, where PG_mlocked is cleared by |