From: Gregory Price <gourry@gourry.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Liu Jing <liujing@cmss.chinamobile.com>,
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 div-by-zero in alloc_pages_bulk_weighted_interleave
Date: Wed, 2 Sep 2026 17:52:33 -0400 [thread overview]
Message-ID: <apiZFrc_ShBRZimV@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260902144039.2824b7589e87dd185c92d67a@linux-foundation.org>
On Wed, Sep 02, 2026 at 02:40:39PM -0700, Andrew Morton wrote:
> On Wed, 2 Sep 2026 09:57:35 -0400 Gregory Price <gourry@gourry.net> wrote:
>
> > On Wed, Sep 02, 2026 at 05:04:12PM +0800, Liu Jing wrote:
> > > In alloc_pages_bulk_weighted_interleave(), if the iw_table contains
> > > all-zero weights for every node in the policy nodemask, weight_total
> > > sums to zero. The subsequent "rem_pages / weight_total" and
> > > "rem_pages % weight_total" trigger a divide-by-zero panic.
> > >
> >
> > weights can't be zero and we just fixed the rebind race
>
> So if the caller passes in me->weight==0 then we consider that caller
> to be buggy.
>
basically weights cannot be 0 by construction:
What: /sys/kernel/mm/mempolicy/weighted_interleave/nodeN
...
The minimum weight for a node is always 1.
What: /sys/kernel/mm/mempolicy/weighted_interleave/auto
...
If they were not previously set or are onlined with missing
bandwidth data, the weights will use a default weight of 1.
int mempolicy_set_node_perf(unsigned int node, struct access_coordinate *coords)
{
...
new_wi_state->mode_auto = true;
for (i = 0; i < nr_node_ids; i++)
new_wi_state->iw_table[i] = 1;
static ssize_t node_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
...
for (i = 0; i < nr_node_ids; i++)
new_wi_state->iw_table[i] = 1;
static ssize_t weighted_interleave_auto_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t count)
{
...
for (i = 0; i < nr_node_ids; i++)
new_wi_state->iw_table[i] = 1;
we default all weights to 1 and never let calculation drop below 1 for
exactly this div/0 reason.
The div/0 risk came solely from the torn nodemask read issue.
~Gregory
prev parent reply other threads:[~2026-09-02 21:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 9:04 [PATCH] mempolicy: fix div-by-zero in alloc_pages_bulk_weighted_interleave Liu Jing
2026-09-02 13:57 ` Gregory Price
2026-09-02 21:40 ` Andrew Morton
2026-09-02 21:52 ` 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=apiZFrc_ShBRZimV@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 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.