All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	akpm@linux-foundation.org, corbet@lwn.net, bijan311@gmail.com,
	ajayjoshi@micron.com, honggyu.kim@sk.com, yunjeong.mun@sk.com
Subject: Re: [PATCH v9] mm/damon: add node_eligible_mem_bp goal metric
Date: Sun, 26 Apr 2026 16:03:21 -0700	[thread overview]
Message-ID: <20260426230322.106206-1-sj@kernel.org> (raw)
In-Reply-To: <20260426213859.1835-1-ravis.opensrc@gmail.com>

[...]
> Changes since v8:
> =================
> https://lore.kernel.org/linux-mm/20260426003245.2687-1-ravis.opensrc@gmail.com/
> 
> - Removed unnecessary casts in mult_frac() call to fix potential
>   divide-by-zero on 32-bit PAE systems (Sashiko/SJ review)
> - Kept original parameter name 'ctx' in damos_set_effective_quota()
>   to avoid unnecessary diff (SJ review)
[...]
> +static unsigned long damos_get_node_eligible_mem_bp(struct damon_ctx *c,
> +		struct damos *s, int nid)
> +{
> +	phys_addr_t total_eligible = 0;
> +	phys_addr_t node_eligible;
> +
> +	if (c->ops.id != DAMON_OPS_PADDR)
> +		return 0;
> +
> +	if (nid < 0 || nid >= MAX_NUMNODES || !node_online(nid))
> +		return 0;
> +
> +	node_eligible = damos_calc_eligible_bytes(c, s, nid, &total_eligible);
> +
> +	if (!total_eligible)
> +		return 0;
> +
> +	return mult_frac(node_eligible, 10000, total_eligible);
> +}

Sashiko found [1] this can cause __udivdi3 linking issue on 32bit machine with
CONFIG_PHYS_ADDR_T_64BIT.  Seems that is correct to me.  I believe below
attaching fixup can fix it?

Ravi, if my fixup looks good to you, could you please post another version
(say, v9.1) for another Sashiko review round?

[1] https://lore.kernel.org/20260426220409.95B26C2BCAF@smtp.kernel.org


Thanks,
SJ

[...]

=== >8 ===
From 828ddfdfa3a996efc4620919a3cc77d55088c466 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Sun, 26 Apr 2026 15:54:48 -0700
Subject: [PATCH] mm/damon/core: avoid __udivdi3 linking issue

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@kernel.org>
---
 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


  parent reply	other threads:[~2026-04-26 23:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-26 21:38 [PATCH v9] mm/damon: add node_eligible_mem_bp goal metric Ravi Jonnalagadda
2026-04-26 22:04 ` sashiko-bot
2026-04-26 23:08   ` SeongJae Park
2026-04-26 23:03 ` SeongJae Park [this message]
2026-04-27  0:59   ` Ravi Jonnalagadda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260426230322.106206-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=ajayjoshi@micron.com \
    --cc=akpm@linux-foundation.org \
    --cc=bijan311@gmail.com \
    --cc=corbet@lwn.net \
    --cc=damon@lists.linux.dev \
    --cc=honggyu.kim@sk.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ravis.opensrc@gmail.com \
    --cc=yunjeong.mun@sk.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.