[PATCH 3/5] mm: add a batched helper to clear the young flag for large folios

Rik van Riel riel at surriel.com
Tue Feb 24 14:03:45 PST 2026


On Tue, 2026-02-24 at 09:56 +0800, Baolin Wang wrote:
> 
> +static inline int test_and_clear_young_ptes(struct vm_area_struct
> *vma,
> +					    unsigned long addr,
> pte_t *ptep,
> +					    unsigned int nr)
> +{
> +	int young = 0;
> +
> +	for (;;) {
> +		young |= ptep_test_and_clear_young(vma, addr, ptep);
> +		if (--nr == 0)
> +			break;
> +		ptep++;
> +		addr += PAGE_SIZE;
> +	}

This may be a nitpick, but could the --nr thing be
stuck into the loop conditional?

Something that looks like an infinite loop just
seems wrong for something so bounded.

-- 
All Rights Reversed.



More information about the linux-arm-kernel mailing list