From: Gregory Price <gourry@gourry.net>
To: Rakie Kim <rakie.kim@sk.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
akpm@linux-foundation.org, david@kernel.org, ziy@nvidia.com,
matthew.brost@intel.com, joshua.hahnjy@gmail.com,
byungchul@sk.com, ying.huang@linux.alibaba.com,
apopple@nvidia.com, urezki@gmail.com, chenwandun@huawei.com,
linux-mm@kvack.org, kernel_team@skhynix.com
Subject: Re: [PATCH 2/2] mm/mempolicy: stop copying the nodemask in the interleave paths
Date: Wed, 2 Sep 2026 10:52:45 -0400 [thread overview]
Message-ID: <apgzMZQPTxS9QtDy@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260902090047.1944-1-rakie.kim@sk.com>
On Wed, Sep 02, 2026 at 06:00:44PM +0900, Rakie Kim wrote:
>
> > @@ -2712,9 +2713,13 @@ static unsigned long alloc_pages_bulk_weighted_interleave(gfp_t gfp,
> > table = state ? state->iw_table : NULL;
> >
> > /* calculate total, detect system default usage */
> > - for_each_node_mask(node, nodes)
> > + for_each_node_mask(node, pol->nodes)
> > weight_total += table ? table[node] : 1;
>
> I have a minor comment on this part. After this change, everything
> else reads pol->nodes fresh at the point of use - the weight sum
> and the walk both look at the current mask. Only nnodes is still
> the count from this earlier read. If the mask changes in between,
> the loop bound no longer matches the mask the loop is actually
> walking, so the walk can stop short of the pages the weight total
> planned for. Would it be better to count the nodes in the loop
> that sums the weights, the way weighted_interleave_nid() does it
> in this patch?
>
I don't think this actually fixes anything?
But basically the proposal is to widen the SRCU() window further to
include the cpuset cookie entirely.
e.g.
SRCU() {
cpuset_cookie() {
for_each_node_mask(node, pol->nodes)
weight_total += ...
nnodes++;
}
/* ... snip - single node quick-exit ... */
/* ... actual multi-node bulk allocation ... */
for_each_node_mask(node, pol->nodes) {
nr_allocated = __alloc_pages_bulk(gfp, node, ...);
/*
* At this point, due to a torn read from pol->nodes
* we can visit a node that wasn't present previously
* or we can skip a node that was present previously.
*
* In either case, weight_total is the wrong value for
* the set of nodes being walked anyway - we are going
* to skew in the distribution no matter what.
*/
}
}
I'm not sure widening the SRCU window is worth it here, it doesn't
actually buy us anything.
Also we'd be calculating the weight total every time even when there's a
scenario where we quick-exit because the entire allocation fits in the
first node in the mask.
> nnodes = 0;
> for_each_node_mask(node, pol->nodes) {
> weight_total += table ? table[node] : 1;
> nnodes++;
> }
>
> [...snip...]
>
> Thanks again for your time.
>
> Rakie Kim
next prev parent reply other threads:[~2026-09-02 14:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-29 1:59 [PATCH 0/2] mm/mempolicy: stop copying state in the interleave paths Gregory Price
2026-08-29 1:59 ` [PATCH 1/2] mm/mempolicy: use SRCU for the weighted interleave state Gregory Price
2026-08-29 1:59 ` [PATCH 2/2] mm/mempolicy: stop copying the nodemask in the interleave paths Gregory Price
2026-09-02 9:00 ` Rakie Kim
2026-09-02 14:52 ` Gregory Price [this message]
2026-08-29 23:18 ` [PATCH 0/2] mm/mempolicy: stop copying state " Andrew Morton
2026-08-30 16:39 ` Gregory Price
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=apgzMZQPTxS9QtDy@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--cc=chenwandun@huawei.com \
--cc=david@kernel.org \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel-team@meta.com \
--cc=kernel_team@skhynix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.brost@intel.com \
--cc=rakie.kim@sk.com \
--cc=urezki@gmail.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