mm,hwpoison: return 0 if the page is already poisoned in soft-offline

Linux Kernel / Linux Kernel - Oscar Salvador [suse.de] - 16 October 2020 18:11 UTC

Currently, there is an inconsistency when calling soft-offline from different paths on a page that is already poisoned.

1) madvise:

madvise_inject_error skips any poisoned page and continues the loop. If that was the only page to madvise, it returns 0.

2) /sys/devices/system/memory/:

When calling soft_offline_page_store()->soft_offline_page(), we return -EBUSY in case the page is already poisoned. This is inconsistent with a) the above example and b) memory_failure, where we return 0 if the page was poisoned.

Fix this by dropping the PageHWPoison() check in madvise_inject_error, and let soft_offline_page return 0 if it finds the page already poisoned.

Please, note that this represents a user-api change, since now the return error when calling soft_offline_page_store()->soft_offline_page() will be different.

5a2ffca3c233 mm,hwpoison: return 0 if the page is already poisoned in soft-offline
mm/madvise.c | 5 -----
mm/memory-failure.c | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)

Upstream: git.kernel.org


  • Share