Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] mm/damon/paddr: prevent address wrap in action walks
@ 2026-12-05  1:52 Kyuwon Cho
  2026-12-05  1:52 ` [PATCH v3 1/4] mm/damon/paddr: prevent address wrap in pageout walks Kyuwon Cho
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kyuwon Cho @ 2026-12-05  1:52 UTC (permalink / raw)
  To: SJ Park, Andrew Morton
  Cc: Quanmin Yan, Aveline Noir, sashiko-bot, sashiko-reviews, damon,
	linux-mm

The four physical-address DAMOS action walks advance a page-aligned cursor
by PAGE_SIZE or folio_size().  If the physical end of a region is near
PHYS_ADDR_MAX, either addition can wrap the cursor to zero.

Depending on where the wrap makes the loop restart, and on the folio
states and sizes in the address range, the walk can repeat multiple times.
In the worst case, it can be infinite.

As a result, kdamond can affect unexpectedly much memory and consume
system resources.  Users cannot stop it because the busy kdamond does not
respond to DAMON sysfs input.  Regions ending near PHYS_ADDR_MAX are rare
in practice, but the consequence is severe.

Calculate each converted end once before its loop and saturate every
PAGE_SIZE or folio-size advance at that end.  Keep the fixes split by the
commits that introduced the walks so they can be backported independently.

---
Changes in v3:
- Restore the impact description, including the indefinite repeat, using
  wording suggested by SJ Park.
- Hoist each end calculation before its loop and fold the separately
  posted endpoint optimization into the fixes, as suggested by SJ Park.
- Correct the Fixes tags after SJ Park noted that the pageout tag was too
  new.  Aveline Noir identified the commit that introduced the pageout
  walk.

The separate endpoint optimization can be dropped:
https://lore.kernel.org/all/179636379461.1106205.7227742056101745798@skku.edu/

The v3 plan discussion:
https://lore.kernel.org/all/179640027323.1616253.15840107925779563493@skku.edu/

v2:
https://lore.kernel.org/all/179636379461.1106205.17118044826561378975@skku.edu/

v1:
https://lore.kernel.org/all/179614474316.1073623.13833808548597202010@skku.edu/

The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

The sysfs test case was posted in the v2 discussion:
https://lore.kernel.org/all/179640027309.1616249.12163670586345074790@skku.edu/

Kyuwon Cho (4):
  mm/damon/paddr: prevent address wrap in pageout walks
  mm/damon/paddr: prevent address wrap in LRU action walks
  mm/damon/paddr: prevent address wrap in migration walks
  mm/damon/paddr: prevent address wrap in stat walks

 mm/damon/paddr.c | 52 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 16 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-05  1:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  1:52 [PATCH v3 0/4] mm/damon/paddr: prevent address wrap in action walks Kyuwon Cho
2026-12-05  1:52 ` [PATCH v3 1/4] mm/damon/paddr: prevent address wrap in pageout walks Kyuwon Cho
2026-12-05  1:52 ` [PATCH v3 2/4] mm/damon/paddr: prevent address wrap in LRU action walks Kyuwon Cho
2026-12-05  1:52 ` [PATCH v3 3/4] mm/damon/paddr: prevent address wrap in migration walks Kyuwon Cho
2026-12-05  1:52 ` [PATCH v3 4/4] mm/damon/paddr: prevent address wrap in stat walks Kyuwon Cho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox