Currently, there is an inconsistency when calling soft-offline from different paths on a page that is already poisoned.
madvise_inject_error skips any poisoned page and continues the loop. If that was the only page to madvise, it returns 0.
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(-)