Re: [PATCH stable-5.10] mm/memory-failure: fix an incorrect use of tail pages

From: Matthew Wilcox
Date: Mon Mar 25 2024 - 08:30:39 EST


On Mon, Mar 25, 2024 at 11:36:49AM +0800, Liu Shixin wrote:
> Hi,
>
> After backport commit c79c5a0a00a9 ("mm/memory-failure: check the mapcount of the precise page"),
>
> I got an error message as written on the patch. The problem can be fixed by the patch or just revert.
>
> Now I prefer to revert because I think it is related to folio and no impact in stable, or maybe I'm wrong.

I checked out what is going wrong here, and Liu Shixin is correct.

Commit c79c5a0a00a9 was incorrectly backported to v5.10 and
commit 70168fdc743b changees the page passed to try_to_unmap().
It now passes the tail page, and should always have passed hpage.
Please apply the patch below to v5.10 (and any other trees that
c79c5a0a00a9 got backported to).

>
> Thanks,
>
>
> On 2024/3/7 20:48, Liu Shixin wrote:
> > When backport commit c79c5a0a00a9 to 5.10-stable, there is a mistake change.
> > The head page instead of tail page should be passed to try_to_unmap(),
> > otherwise unmap will failed as follows.
> >
> > Memory failure: 0x121c10: failed to unmap page (mapcount=1)
> > Memory failure: 0x121c10: recovery action for unmapping failed page: Ignored
> >
> > Fixes: 70168fdc743b ("mm/memory-failure: check the mapcount of the precise page")
> > Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx>
> > ---
> > mm/memory-failure.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> > index f320ff02cc19..dba2936292cf 100644
> > --- a/mm/memory-failure.c
> > +++ b/mm/memory-failure.c
> > @@ -1075,7 +1075,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
> > unmap_success = false;
> > }
> > } else {
> > - unmap_success = try_to_unmap(p, ttu);
> > + unmap_success = try_to_unmap(hpage, ttu);
> > }
> > }
> > if (!unmap_success)
>
>