[PATCH] mm/damon/core: avoid __udivdi3 linking issue
From: SeongJae Park
Date: Sun Apr 26 2026 - 18:54:48 EST
On 32bit machines having PHYS_ADDR_T_64BIT, mult_frac() with phys_addr_t
will cause __udivdi3 linking issue. Cast values to 'unsigned long'
before calling mult_frac(). This could cause divide-by-zero if the
denominator becomes zero by casting. Avoid it by checking the zero case
with the casted value.
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/damon/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 0ea747d487465..aec43314fc4a9 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2921,10 +2921,11 @@ static unsigned long damos_get_node_eligible_mem_bp(struct damon_ctx *c,
node_eligible = damos_calc_eligible_bytes(c, s, nid, &total_eligible);
- if (!total_eligible)
+ if (!(unsigned long)total_eligible)
return 0;
- return mult_frac(node_eligible, 10000, total_eligible);
+ return mult_frac((unsigned long)node_eligible, 10000,
+ (unsigned long)total_eligible);
}
#else /* CONFIG_DAMON_PADDR */
static unsigned long damos_get_node_eligible_mem_bp(struct damon_ctx *c,
--
2.47.3