Re: [PATCH] mm/hugetlb: Use max() to simplify hugetlb_vmemmap_optimizable_size()

From: Matthew Wilcox
Date: Sun Aug 10 2025 - 20:15:49 EST


On Sun, Aug 10, 2025 at 11:47:45PM +0200, Thorsten Blum wrote:
> Use max() to simplify hugetlb_vmemmap_optimizable_size() and improve its
> readability.

That ... isn't clearer.

> {
> - int size = hugetlb_vmemmap_size(h) - HUGETLB_VMEMMAP_RESERVE_SIZE;
> -
> if (!is_power_of_2(sizeof(struct page)))
> return 0;
> - return size > 0 ? size : 0;
> +
> + return max(0, hugetlb_vmemmap_size(h) - HUGETLB_VMEMMAP_RESERVE_SIZE);
> }