Re: [PATCH mm-unstable v2 3/5] mm/khugepaged: define COLLAPSE_MAX_PTES_LIMIT as HPAGE_PMD_NR - 1

From: Nico Pache

Date: Thu Feb 26 2026 - 15:23:56 EST


On Thu, Feb 26, 2026 at 2:28 AM David Hildenbrand (Arm)
<david@xxxxxxxxxx> wrote:
>
> On 2/26/26 02:29, Nico Pache wrote:
> > The value (HPAGE_PMD_NR - 1) is used often in the khugepaged code to
> > signify the limit of the max_ptes_* values. Add a define for this to
> > increase code readability and reuse.
> >
> > Acked-by: Pedro Falcato <pfalcato@xxxxxxx>
> > Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> > Signed-off-by: Nico Pache <npache@xxxxxxxxxx>
> > ---
> > mm/khugepaged.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index 2ef4b972470b..4615f34911d1 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -89,6 +89,7 @@ static DECLARE_WAIT_QUEUE_HEAD(khugepaged_wait);
> > *
> > * Note that these are only respected if collapse was initiated by khugepaged.
> > */
> > +#define COLLAPSE_MAX_PTES_LIMIT (HPAGE_PMD_NR - 1)
>
> I'd call it "KHUGEPAGED_MAX_PTES_LIMIT", because it's khugepaged
> specific (no madvise) and matches the parameters.

Ok before changing that, note that this is also leveraged in the mTHP
set. It's technically used for madvise collapse because when it's not
khugepaged we set max_ptes_none= 511.

But I'm ok with either name! I just want to make sure it makes sense
for the later users too.

Thanks :)
-- Nico

>
> Apart from that
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>
> --
> Cheers,
>
> David
>