Re: [PATCH] mm/huge_memory: update file PUD counter before folio_put()
From: Lorenzo Stoakes
Date: Tue May 26 2026 - 06:57:16 EST
On Tue, May 26, 2026 at 06:53:05PM +0800, Yin Tirui wrote:
>
> On 5/26/2026 6:47 PM, Lorenzo Stoakes wrote:
> > You sent this twice :)
Yeah oops you didn't, that was just the PMD part!
(Also my mail client may now, ironically, duplicate a reply...)
> >
> > On Tue, May 26, 2026 at 06:13:55PM +0800, Yin Tirui wrote:
> > > __split_huge_pud_locked() updates the file/shmem RSS counter after
> > > dropping the PUD mapping's folio reference. If folio_put() drops the
> > > last reference, mm_counter_file() can later read freed folio state via
> > > folio_test_swapbacked().
> > >
> > > Move the counter update before folio_put().
> > >
> > > Fixes: dbe54153296d ("mm/huge_memory: add vmf_insert_folio_pud()")
> > > Cc: <stable@xxxxxxxxxxxxxxx>
> > > Signed-off-by: Yin Tirui <yintirui@xxxxxxxxxx>
> > Patch looks sane to me, so:
> >
> > Reviewed-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>
> >
> > There seems to be an identical problem in __split_huge_pmd_locked() - could you
> > do the same fix there?
>
> I have already sent it as another separate patch.
>
> https://lore.kernel.org/linux-mm/20260526101337.1984081-1-yintirui@xxxxxxxxxx/T/#u
Yup, inevitably hit send and only then notice this :)
Cheers, Lorenzo