Re: [PATCH] mm/huge_memory: fix swap entry values of tail pages of THP

From: Greg KH
Date: Mon Mar 04 2024 - 05:49:35 EST


On Wed, Feb 28, 2024 at 09:06:19PM +0530, Charan Teja Kalla wrote:
> Thanks David/Zi Yan,
>
> On 2/27/2024 9:45 PM, Zi Yan wrote:
> > So likely we'd have to fix the stable kernels:
> >
> > 4.19
> > 5.4
> > 5.10
> > 5.15
> > 6.1
> >
> > That's a lot of pre-folio code. A backport of my series likely won't really make any sense.
>
> So, I assume this is a consensus to have stable-only fix for this issue.
>
> >
> > For v6.1, the fix would like below?
> >
> > diff --git a/mm/migrate.c b/mm/migrate.c
> > index c93dd6a31c31..c5968021fde0 100644
> > --- a/mm/migrate.c
> > +++ b/mm/migrate.c
> > @@ -423,8 +423,12 @@ int folio_migrate_mapping(struct address_space *mapping,
> > if (folio_test_swapbacked(folio)) {
> > __folio_set_swapbacked(newfolio);
> > if (folio_test_swapcache(folio)) {
> > + int i;
> > +
> > folio_set_swapcache(newfolio);
> > - newfolio->private = folio_get_private(folio);
> > + for (i = 0; i < nr; i++)
> > + set_page_private(folio_page(newfolio, i),
> > + page_private(folio_page(folio, i)));
> > }
> > entries = nr;
> > } else {
>
> Similar to this is what we had tested[1] internally and observed no issues.
>
> Can this be taken to 6.1, please?

Someone needs to submit it properly and get it reviewed by the relevent
maintainers.

thanks,

greg k-h