Thread (23 messages) 23 messages, 5 authors, 2026-02-26

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

From: Baolin Wang <baolin.wang@linux.alibaba.com>
Date: 2026-02-25 02:05:11
Also in: linux-mm, lkml


On 2/25/26 6:03 AM, Rik van Riel wrote:
On Tue, 2026-02-24 at 09:56 +0800, Baolin Wang wrote:
quoted
+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.
It seems that people have different preferences regarding loop patterns.

The current code keeps this loop pattern consistent with other similar 
functions in the same file, as previously suggested by David [1].

[1] 
https://lore.kernel.org/all/3d5cb9a4-6604-4302-a110-3d8ff91baa56@kernel.org/ (local)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help