Skip to content

Commit b94e028

Browse files
osalvadorvilardagatorvalds
authored andcommitted
mm,hwpoison: try to narrow window race for free pages
Aristeu Rozanski reported that a customer test case started to report -EBUSY after the hwpoison rework patchset. There is a race window between spotting a free page and taking it off its buddy freelist, so it might be that by the time we try to take it off, the page has been already allocated. This patch tries to handle such race window by trying to handle the new type of page again if the page was allocated under us. Reported-by: Aristeu Rozanski <[email protected]> Signed-off-by: Oscar Salvador <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Aristeu Rozanski <[email protected]> Acked-by: Naoya Horiguchi <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Dmitry Yakunin <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Qian Cai <[email protected]> Cc: Tony Luck <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1f2481d commit b94e028

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mm/memory-failure.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,7 @@ int soft_offline_page(unsigned long pfn, int flags)
19031903
{
19041904
int ret;
19051905
struct page *page;
1906+
bool try_again = true;
19061907

19071908
if (!pfn_valid(pfn))
19081909
return -ENXIO;
@@ -1918,14 +1919,18 @@ int soft_offline_page(unsigned long pfn, int flags)
19181919
return 0;
19191920
}
19201921

1922+
retry:
19211923
get_online_mems();
19221924
ret = get_any_page(page, pfn, flags);
19231925
put_online_mems();
19241926

19251927
if (ret > 0)
19261928
ret = soft_offline_in_use_page(page);
19271929
else if (ret == 0)
1928-
ret = soft_offline_free_page(page);
1930+
if (soft_offline_free_page(page) && try_again) {
1931+
try_again = false;
1932+
goto retry;
1933+
}
19291934

19301935
return ret;
19311936
}

0 commit comments

Comments
 (0)