Re: [PATCH 2/5] mm/khugepaged: use slab cache instead of normal kmalloc

From: Luka Bai

Date: Wed Jun 10 2026 - 23:16:42 EST


在 Tue, Jun 09, 2026 at 12:26:18PM +0200,Vlastimil Babka (SUSE) 写道:
> On 5/31/26 06:23, Luka Bai wrote:
> > From: Luka Bai <lukabai@xxxxxxxxxxx>
> >
> > We added a kmem slab cached called collapse_hint_cache for
> > khugepaged collapse hint, to improve the performance in allocation
> > and freeing for the hint structs.
> >
> > Signed-off-by: Luka Bai <lukabai@xxxxxxxxxxx>
>
> Khugepaged isn't exactly a hotpath? Adding own cache comes with memory
> overhead, so this doesn't seem like a sufficient reason to do that.
>
Hi Vlastimil,

Thanks for the review :).

Yeah Khugepaged is not a hotpath. But in my implementation we will allocate
those khugepaged collapse hint structs in other paths like walk_mm() and
lru_gen_look_around(), which may be called more frequently under memory
pressure. I'm a little afraid that directly using kmalloc may compromise
the performance of reclaimation... What do you think? Thanks. :)

Best regards,
Luka