Re: [PATCH 0/5] mm/khugepaged: add collapse hint machanism for khugepaged and use in mglru

From: Luka Bai

Date: Wed Jun 10 2026 - 23:07:24 EST


在 Tue, Jun 09, 2026 at 04:17:45AM -0600,Nico Pache 写道:

Hi Nico,

Thanks for the reply. :)

> On Sat, May 30, 2026 at 10:33 PM Luka Bai <lukafocus@xxxxxxxxxx> wrote:
>
> Hi Luka,
>
> I haven't reviewed the code yet, but the overall concept is
> interesting (it should probably be a RFC first though, but that's
> fine).
>

Sorry for the RFC mistake that I made. I didn't know the difference between
an RFC submission and a normal one. I'll use the correct type from now on.
Thanks for reminding me :)

> I had future plans for something similar as part of the thp=auto work;
> however that requires significant thought and investigation into how
> we can properly gather hints for collapse/split THP candidates. From
> my perspective we'd want a more global structure/system outside of
> khugepaged, that would directly call khugepaged (and others like
> split, etc). It would also tie into the allocator so that at fault
> time it could leverage the hints to make better decisions. My fear
> with this series is that making a decision now might complicate future
> work by adding complexity we may eventually want to remove for a
> better solution.
>
> If you have the chance perhaps you can lead a discussion on your
> proposal at the biweekly MM alignment session.
>
> +David Rientjes as he leads those discussions. We could use that time
> to layout a plan for what needs to be done for this work, and for the
> work surrounding thp=auto as I beleive they will be interdependent :)

That is a great idea! I also believe that we should improve THP in all sorts
of places like page allocation to use THP more precisely and more easily,
considering the fraction problem that is common when the machine runs. After
all, our goal is to maximize the benifit that THP can give by optimizing all
the routes :). Actually I've prepared another patchset that gives THP the
ability to be reserved based on migratetype so that we can reduce the fraction
of THP folios, and was considering discussing it with the upstream. But I
guess I'll postpone it after the reconstruction of THP code base as proposed by
Lorenzo :). I'm very interested in these discussions about the THP hints or
auto and reconstructions. Maybe we can use the THP cabal meeting mentioned by
Lorenzo for the discussion? Any approach is fine for me. Thanks. :)

>
> Cheers,
> -- Nico
>
> >
> > Signed-off-by: Luka Bai <lukabai@xxxxxxxxxxx>
> > ---
> > Luka Bai (5):
> > mm/khugepaged: add framework for khugepaged collapse hint
> > mm/khugepaged: use slab cache instead of normal kmalloc
> > mm/khugepaged: add deduplication when adding new collapse hint
> > mm/khugepaged: add accounting for successful hint or non-hint collapse
> > mm/khugepaged: add khugepaged collapse hint in mglru reference checking
> >
> > include/linux/huge_mm.h | 2 +
> > include/linux/khugepaged.h | 20 ++
> > include/linux/mmzone.h | 17 +-
> > mm/huge_memory.c | 4 +
> > mm/khugepaged.c | 460 ++++++++++++++++++++++++++++++++++++++++++++-
> > mm/rmap.c | 27 ++-
> > mm/vmscan.c | 33 +++-
> > 7 files changed, 549 insertions(+), 14 deletions(-)
> > ---
> > base-commit: e1af79f3291a268adf4e149e1faba3052743e898
> > change-id: 20260530-thp_collapse_hint-ec92bd943797
> >
> > Best regards,
> > --
> > Luka Bai <lukabai@xxxxxxxxxxx>
> >
>

Best regards,
Luka