Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gregory Price <gourry@gourry.net>
To: Liu Jing <liujing@cmss.chinamobile.com>
Cc: akpm@linux-foundation.org, david@kernel.org, ziy@nvidia.com,
	 matthew.brost@intel.com, joshua.hahnjy@gmail.com,
	rakie.kim@sk.com, byungchul@sk.com,
	 ying.huang@linux.alibaba.com, apopple@nvidia.com,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mempolicy: fix mod-by-zero in weighted_interleave_nid
Date: Wed, 2 Sep 2026 09:58:48 -0400	[thread overview]
Message-ID: <apgrXDZ_dOz2hRJ3@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260902090346.16429-1-liujing@cmss.chinamobile.com>

On Wed, Sep 02, 2026 at 05:03:46PM +0800, Liu Jing wrote:
> In weighted_interleave_nid(), if the iw_table contains all-zero
> weights for every node in the policy nodemask, weight_total sums to
> zero. The subsequent "ilx % weight_total" triggers a divide-by-zero
> panic.
> 

weights can't be zero and we just fixed the rebind race

if you're actually seeing this then there's a different bug to fix

> Add a zero check returning the current NUMA node id when the total
> weight is zero, consistent with the existing !nr_nodes guard.
> 
> Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
> ---
>  mm/mempolicy.c | 4 ++++
>  1 file changed, 4 insertion(+), 0 deletion(-)
> 
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2218,6 +2218,10 @@
>  	/* calculate the total weight */
>  	for_each_node_mask(nid, nodemask)
>  		weight_total += table ? table[nid] : 1;
> +
> +
> +	if (!weight_total)
> +		return numa_node_id();
>  
>  	/* Calculate the node offset based on totals */
>  	target = ilx % weight_total;
> 
> --
> 2.43.0
> 
> 


      reply	other threads:[~2026-09-02 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  9:03 [PATCH] mempolicy: fix mod-by-zero in weighted_interleave_nid Liu Jing
2026-09-02 13:58 ` Gregory Price [this message]

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=apgrXDZ_dOz2hRJ3@gourry-fedora-PF4VCD3F \
    --to=gourry@gourry.net \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liujing@cmss.chinamobile.com \
    --cc=matthew.brost@intel.com \
    --cc=rakie.kim@sk.com \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox