Re: [PATCH v3 1/3] mm: pagewalk: simplify hugepage boundary calculation using min()

David Laight
2025-11-27T10:05:31Z

On Thu, 27 Nov 2025 10:41:28 +0530
Sahil Chandna <chandna.sahil@gmail.com> wrote:

> Use the min() macro to compute the minimum value instead of an explicit
> ternary expression. This improves readability and matches common kernel
> style. Also change the return hugepage boundary expression for better
> clarity.
>
>...
> {
> - unsigned long boundary = (addr & huge_page_mask(h)) + huge_page_size(h);
> - return boundary < end ? boundary : end;
> + return min(ALIGN(addr, huge_page_size(h)), end);
> }
>
> static int walk_hugetlb_range(unsigned long addr, unsigned long end,

The commit message doesn't really match the patch.
The biggest part is not open-coding the equivalent of ALIGN(), not using min().

David