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

From: David Hildenbrand (Arm)

Date: Thu Feb 26 2026 - 04:42:35 EST


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.

Apart from that

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David