* [RFC PATCH] mm/damon: handle zero sampling interval in damon_max_nr_accesses()
@ 2026-06-19 20:51 SeongJae Park
0 siblings, 0 replies; only message in thread
From: SeongJae Park @ 2026-06-19 20:51 UTC (permalink / raw)
Cc: SeongJae Park, # 5 . 16 . x, Andrew Morton, damon, linux-kernel,
linux-mm
damon_max_nr_accesses() causes divide-by-zero if sampling interval is
zero. Fix it by handling the case.
The issue was dicovered [1] by Sashiko.
[1] https://lore.kernel.org/20260619202459.145010-1-sj@kernel.org
Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization")
Cc: <stable@vger.kernel.org> # 5.16.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/linux/damon.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 64d75c78f4df4..b6fbe6089abc6 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -1066,8 +1066,10 @@ static inline bool damon_target_has_pid(const struct damon_ctx *ctx)
static inline unsigned int damon_max_nr_accesses(const struct damon_attrs *attrs)
{
+ unsigned long sample_interval = attrs->sample_interval ? : 1;
+
/* {aggr,sample}_interval are unsigned long, hence could overflow */
- return min(attrs->aggr_interval / attrs->sample_interval,
+ return min(attrs->aggr_interval / sample_interval,
(unsigned long)UINT_MAX);
}
base-commit: 7a58ae62cdf3c006a53b805bbb12079ab2621a07
--
2.47.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-19 20:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-19 20:51 [RFC PATCH] mm/damon: handle zero sampling interval in damon_max_nr_accesses() SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox