Re: [PATCH] mm,hwpoison: Return -EBUSY when migration fails

From: Vlastimil Babka
Date: Wed Dec 09 2020 - 05:26:33 EST


On 12/9/20 10:28 AM, Oscar Salvador wrote:
> Currently, we return -EIO when we fail to migrate the page.
>
> Migrations' failures are rather transient as they can happen due to
> several reasons, e.g: high page refcount bump, mapping->migrate_page
> failing etc.
> All meaning that at that time the page could not be migrated, but
> that has nothing to do with an EIO error.
>
> Let us return -EBUSY instead, as we do in case we failed to isolate
> the page.
>
> While are it, let us remove the "ret" print as its value does not change.
>
> Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>

Technically this affects madvise(2) so let's cc linux-api. The manpage doesn't
document error codes of MADV_HWPOISON and MADV_SOFT_OFFLINE (besides EPERM)
though so nothing to adjust there. It's meant only for the hwpoison testing
suite anyway.

> ---
> mm/memory-failure.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 428991e297e2..1942fb83ac64 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1849,11 +1849,11 @@ static int __soft_offline_page(struct page *page)
> pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n",
> pfn, msg_page[huge], ret, page->flags, &page->flags);
> if (ret > 0)
> - ret = -EIO;
> + ret = -EBUSY;
> }
> } else {
> - pr_info("soft offline: %#lx: %s isolation failed: %d, page count %d, type %lx (%pGp)\n",
> - pfn, msg_page[huge], ret, page_count(page), page->flags, &page->flags);
> + pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %lx (%pGp)\n",
> + pfn, msg_page[huge], page_count(page), page->flags, &page->flags);
> ret = -EBUSY;
> }
> return ret;
>