Re: [PATCH 18/60] mm/khugepaged: base the recommended min_free_kbytes on common memory
From: Gregory Price (Meta)
Date: Mon Nov 23 2026 - 09:02:46 EST
On 2026-11-22 11:41 -0500, Yury Norov wrote:
> On Fri, Nov 20, 2026 at 01:09:09PM -0500, Gregory Price via B4 Relay wrote:
> > From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
> >
> > set_recommended_min_free_kbytes() reserves two pageblocks per populated
> > zone to help THP allocations avoid fragmentation. The reserve serves
> > ordinary allocations, which use only common memory, so count only the
> > zones on N_MEMORY_COMMON nodes.
> >
> > Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> > ---
> > mm/khugepaged.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index 2dc4245814df..a930d99f89da 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -3151,6 +3151,9 @@ void set_recommended_min_free_kbytes(void)
> > }
> >
> > for_each_populated_zone(zone) {
> > + if (!node_state(zone_to_nid(zone), N_MEMORY_COMMON))
> > + continue;
>
> This is the 2nd time you add this check. Maybe fold it into the
> for_each()? Assuming, you keep N_MEMORY meaning unchanged, that would
> look like:
>
> #define for_each_populated_zone_state(zone, state) \
> for (zone = (first_online_pgdat())->node_zones; \
> zone; \
> zone = next_zone(zone)) \
> if (!populated_zone(zone) || \
> !node_state(zone_to_nid(zone), state)) \
> ; /* do nothing */ \
> else
>
> #define for_each_populated_n_memory_zone(zone) \
> for_each_populated_zone_state(zone, N_MEMORY)
>
>
thats reasonable, thanks!
--
~Gregory