From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796351223; b=WId6++uC8x9oUhE0m+40qm4UnmWPtX4B+/dsbR14RWaXT3QQUfUT5maC/SN1qi272ztK yAxnr/ec1wDe16a70narE+Qt/pAZeGoxd8DKmwBRcfcPPy5PrbcAiSxc8unsKw+aBSP78 fkaKerQqYNiL0/v3Jx9D7O3rB5duaNJe1krwPzoscv6z/0z9AMO5GPmcJkYIq7OYMIgLi orymUmXs2ZLBTN38BjiLAJX5IkkuQeZg6mal4kHfJeY+g7SHDoMkhg5qZmnL1GXNlgkDu 8eMhYOj8MXQbxA66GkPNohgZnEpUMtIrMxhTVLuUZ9rKyhViBKNS1b6YMbAIKfYHzdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796351223; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=xL28kGMcgSsaJNrG77D6OSESgkYQDJaljK8FDvzYktE=; b=dokCgS6MdW32nwqqObtYvP9rjBLR8cptIx9asio1wEzcdLc+BPLUB4HRGhbfGSkKac0C bFdNq9NMyG53vtc7uWbjpASTOXp1xQAazDZlmZWTgrzMrvh0SQCUI4FmK2ABhMR5vv09l SNw2EbYpGbB6DUpoxHSUOdeO6tET8sjB+BPiupb0E6JATo/MFGQOETkgnnysd/k1WSjtt S5Plvg4c+ho12tudxOtqqLMkTmFCachFWZFIT+Yf3WAkHayd4JPBkt53fKmuvupCjdIGm OuGg/675Z6e9/R7BuE1BInwoHJjBqleU2Ebh6uX0MRKJ4JSc1fuaLfhZhwg7NaEekEg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GAdspGGr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0A77606A322 for ; Fri, 4 Dec 2026 02:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GAdspGGr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E7981F000C2; Fri, 4 Dec 2026 02:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796351222; bh=xL28kGMcgSsaJNrG77D6OSESgkYQDJaljK8FDvzYktE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GAdspGGrKgXwJddFD+KhnsXTFDk46228KEqrcRbT8x1rGT5w3aN5NcKZ8C59pdxjB MWJByWBSo+xQ23W4eUiiX2GAzkLHJwPcIHmLmj4ydEPev3hIPTUNtBaV7yIea/fT6k B7z0+D14D56qUf+xD0DaifSW1XlEU+CHWTTD/jXPUbVhXETPWFj895L3eKygceddgO n7whT3JtaV42aU1IA5HQRf1gIykYXP6biEB86NRbgaDyYwCnKU+1E6jaGX/pfM4TVD vyMZrX2uG2Ywka0oxEEgENxlzaORO/RyC9nl4b4RGpH7YJL8lXLHJHWNwS2qhqxDqc UIfvb6OhOjrvg== From: SJ Park To: SJ Park Cc: Kyuwon Cho , Andrew Morton , Quanmin Yan , damon@lists.linux.dev, linux-mm@kvack.org Subject: Re: [PATCH] mm/damon/paddr: prevent address wrap in action walks Date: Thu, 3 Dec 2026 18:26:54 -0800 Message-ID: <20261204022655.740410-1-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261204015323.739742-1-sj@kernel.org> References: X-Mailing-List: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 3 Dec 2026 17:53:23 -0800 SJ Park wrote: > Hello Kyuwon, > > On Fri, 4 Dec 2026 01:43:55 +0900 Kyuwon Cho wrote: > > > The physical-address DAMOS action loops advance their cursor by PAGE_SIZE > > or folio_size(). A region whose converted end is near the maximum > > physical address can make that addition wrap to zero. The loop condition > > remains true and the DAMON worker scans almost the entire physical address > > domain. Control operations such as damon_stop() then cannot complete: > > > > INFO: task test:117 blocked for more than 10 seconds. > > Call Trace: > > __schedule (kernel/sched/core.c:7437) > > schedule (kernel/sched/core.c:7529) > > schedule_timeout (kernel/time/sleep_timeout.c:75) > > wait_for_completion (kernel/sched/completion.c:153) > > kthread_stop (kernel/kthread.c:760) > > kthread_stop_put (kernel/kthread.c:781) > > damon_stop (mm/damon/core.c:2207) > > kernfs_fop_write_iter (fs/kernfs/file.c:345) > > Thank you for finding and sharing this problem! > > > > > Calculate each converted end once > > I agree this is a good optimization. But not related to the abovely explained > problem. Hence shouldn't be a part of this patch, in my opinion. Please split > the change out to another patch, and post separately. > > > and saturate every page or folio advance > > at that end. > > Makes sense to me. > > > Apply the same cursor handling to pageout, LRU deactivation, > > migration, and stat actions because all four use the same open-ended > > addition. > > Doing these all in a single patch could make it difficult to backport on > certain stable kernels. Could you please find 'Fixes:' for each of the four > uses, and make patches for the each fix? > > > > > Fixes: 85246435b249 ("mm/damon/paddr: support addr_unit for DAMOS_PAGEOUT") > > I think the fix patches would deserve Cc: stable@. > > > Signed-off-by: Kyuwon Cho > > --- > > The issue was found by an LLM-guided test generator that we are > > developing as a research prototype. The reproducer configures one paddr > > region whose addr_unit conversion ends at PHYS_ADDR_MAX, starts a DAMOS > > action, and requests that DAMON stop. With the patch the cursor reaches > > the region end without wrapping and the stop request returns. > > > > Found and tested on mainline fe6ff8d5d675 (v7.4-rc5); the patch is > > against the DAMON next tree at 88b4c437ff4c. > > > > mm/damon/paddr.c | 46 ++++++++++++++++++++++++++++++---------------- > > 1 file changed, 30 insertions(+), 16 deletions(-) > > > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > > index 2292f0d1aca9..cb67e0cd657d 100644 > > --- a/mm/damon/paddr.c > > +++ b/mm/damon/paddr.c > > @@ -36,6 +36,12 @@ static unsigned long damon_pa_core_addr( > > return pa / addr_unit; > > } > > > > +static phys_addr_t damon_pa_next_addr(phys_addr_t addr, phys_addr_t end, > > + unsigned long size) > > +{ > > + return end - addr <= size ? end : addr + size; > > I'd prefer having safe case first. E.g., > > return addr < end - size ? addr + size : end; Thinking again, end might be smaller than size. Maybe below? size < end - addr ? addr + size : end; Thanks, SJ > > Could you please use that? > > Also, as the code looks intuitive, I don't really feel like this helper > function is needed. What do you think? > > > Thanks, > SJ > > [...] > Thanks, SJ