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=1796349216; b=2SDGdEiYBmTJ0/WVjRHgxxqayyUNSYaBaoL77DqkZGZkBX8ehJtS5Hfsm+OwxkXC1LqD 2+27ocM8xc+em5S3rVat54DwlqYngU4Tts2GOxAFDB1XiWhmNOjEMkm12ZDhgM/b0HwsW Souh8hN/t+EedA3RRTUYcOPr4u+2ayv3djUCln4WQfQjWACx4SM7V76N8tfXHljiYmBja MSb5GQB2CBvHVIdlAp8JtYb6AJEaIL88fQ366XgPUxkhEW+ts1HcaFl7s/JVVwaRLhUU3 qkMB4jFfdTcrAYCH+cbUys/woZJWDuC58Bfq+7EuRqyGh0oRfpwL66BZQy+jgCM3zSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796349216; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Q3VwhxBUgzGevDOrlRH6Ed2RbVncyXFlhrsZ/t1vK6Q=; b=CeMen7f0YT325BgCgghAuPdkI7Bdht1+/bQBZboQQA1Jnq6ClMRZXumsT+60m4JXciiT ob9EtFzA3nHnKNNk/fc85Xsr1CLOg1s8JZirhQCuoiVm/K6Vruyk7pDYci6N01fsRpZeG PwNJJKw8I2fWIjZLT0Wadb6W8x2aaHlKPhi9f/qYqWk3oBCH1zHQX7LmBV9xB9zF5vi2w DW07GM6/KMelRaaTr00JWsttxkl1BbteOda1lnk33U5CSLV5W46h3W4cLOtb93E2eI0UU 7vZBp3lE4PKzfulTg4nC5HpLu5s4TIi7HJzpVu/1teN8kWujiV5XKg6QIYEyg3AbG2A== 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=HDI1SrMP; 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 9E13F606A322 for ; Fri, 4 Dec 2026 01:53:36 +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=HDI1SrMP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CDD31F000C2; Fri, 4 Dec 2026 01:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796349216; bh=Q3VwhxBUgzGevDOrlRH6Ed2RbVncyXFlhrsZ/t1vK6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HDI1SrMPtNysLfpJyr0hFB6mQ3z4LOyoUI4RqZWCzMd12wzY4EQHEn1nJ5O7j01VA g9JCFOIKuDxG14Eoa6LJyKku9X9EhieqWrSUrR/lAjGLcrUSRnCsLvflO5vTFdIgl6 0rsTQ+i+RHUmC/FGZaECku8+SAhbsAFDSemf9i/S7fAqok1tr8Jygy40tlwjbTFTAT Jg4iL55hq5mrLXMvjEAmfCVXI0RSCYDeuRDqHVLdasPOFkdf0UZgoNDOu0AdxyegD7 19y6EWWweyHL6RMvi02LK4xfP4FRVbi0WsWCEatdfEcfBQ6IL+SD0yafmLiu1JXHPn 6NQZ6ma8i/IBw== From: SJ Park To: Kyuwon Cho Cc: SJ Park , 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 17:53:23 -0800 Message-ID: <20261204015323.739742-1-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <179614474316.1073623.13833808548597202010@skku.edu> 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 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; 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 [...]