From: Gregory Price <gourry@gourry.net>
To: Waiman Long <longman@redhat.com>
Cc: "Ridong Chen" <ridong.chen@linux.dev>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Li Zefan" <lizefan@huawei.com>,
"Farhad Alemi" <farhad.alemi@berkeley.edu>,
"Andrew Morton" <akpm@linux-foundation.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
"Aaron Tomlin" <atomlin@atomlin.com>,
"Guopeng Zhang" <guopeng.zhang@linux.dev>,
"David Hildenbrand" <david@kernel.org>
Subject: Re: [PATCH v7 2/9] cgroup/cpuset: Fix node inconsistencies between cpuset_update_tasks_nodemask() and cpuset_attach()
Date: Tue, 23 Jun 2026 12:16:06 -0400 [thread overview]
Message-ID: <ajqxRrhlglVqAeyu@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260621032816.1806773-3-longman@redhat.com>
On Sat, Jun 20, 2026 at 11:28:09PM -0400, Waiman Long wrote:
> Whenever memory node mask is changed, there are 4 places where the node
> mask has to be updated or used.
> 1) task's node mask via cpuset_change_task_nodemask()
> 2) memory policy binding via mpol_rebind_mm()
> 3) if memory migration is enabled, migrate from old_mems_allowed to
> the new node mask via cpuset_migrate_mm().
> 4) setting old_mems_allowed
>
> These memory actions are done in cpuset_update_tasks_nodemask() and
> cpuset_attach(). However there are inconsistencies in what node masks
> are being used in these 2 functions.
>
> In cpuset_update_tasks_nodemask(),
> - cpuset_change_task_nodemask(): guarantee_online_mems()
> - mpol_rebind_mm(): mems_allowed
> - cpuset_migrate_mm(): guarantee_online_mems()
> - old_mems_allowed: guarantee_online_mems()
>
> In cpuset_attach(),
> - cpuset_change_task_nodemask(): guarantee_online_mems()
> - mpol_rebind_mm(): effective_mems
> - cpuset_migrate_mm(): effective_mems
> - old_mems_allowed: effective_mems
>
> These inconsistencies dates back to quite a long time ago and it is
> hard to say what should be the correct values.
>
> The guarantee_online_mems() function returns a node mask from current or
> an ancestor cpuset that is a subset of node_states[N_MEMORY]. Nodes in
> node_states[N_MEMORY] are all online, i.e. in node_states[N_ONLINE].
> However, node in node_states[N_ONLINE] may not have memory. So
> node_states[N_MEMORY] should be a subset of node_states[N_ONLINE].
>
> The guarantee_online_mems() function should mostly be useful for v1
> where mems_allowed is the same as effective_mems. With v2, the memory
> nodes in effective_mems should be a subset of node_states[N_MEMORY]
> except when a memory hot-unplug operation is in progress and a memory
> node is removed from node_states[N_MEMORY] but not yet reflected in
> the effective_mems's as cpuset_handle_hotplug() has not been called
> from cpuset_track_online_nodes().
>
> Let use the following setup for both of them and make them consistent.
> - cpuset_change_task_nodemask(): guarantee_online_mems()
> - mpol_rebind_mm(): effective_mems
> - cpuset_migrate_mm(): guarantee_online_mems()
> - old_mems_allowed: guarantee_online_mems()
>
> So for v2, it is effectively all effective_mems most of the time. For
> v1, mpol_rebind_mm() uses mems_allowed which may differ from what
> guarantee_online_mems() returns, but it conforms to what the cpuset v1
> documentation says with respect to setting memory policy.
>
> Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> kernel/cgroup/cpuset.c | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
Reviewed-by: Gregory Price <gourry@gourry.net>
next prev parent reply other threads:[~2026-06-23 16:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 3:28 [PATCH v7 0/9] cgroup/cpuset: Support multiple source/destination cpusets for cpuset_*attach() Waiman Long
2026-06-21 3:28 ` [PATCH v7 1/9] cgroup/cpuset: rebind mm mempolicy to effective_mems, not mems_allowed Waiman Long
2026-06-22 1:42 ` Ridong Chen
2026-06-23 16:13 ` Gregory Price
2026-06-21 3:28 ` [PATCH v7 2/9] cgroup/cpuset: Fix node inconsistencies between cpuset_update_tasks_nodemask() and cpuset_attach() Waiman Long
2026-06-23 16:16 ` Gregory Price [this message]
2026-06-21 3:28 ` [PATCH v7 3/9] cgroup/cpuset: Prevent race between task attach and cpuset state change Waiman Long
2026-06-22 2:21 ` Ridong Chen
2026-06-25 18:16 ` Waiman Long
2026-06-21 3:28 ` [PATCH v7 4/9] cgroup/cpuset: Add a cpuset_reserve_dl_bw() helper Waiman Long
2026-06-23 16:18 ` Gregory Price
2026-06-21 3:28 ` [PATCH v7 5/9] cgroup/cpuset: Expand the scope of cpuset_can_attach_check() Waiman Long
2026-06-21 3:28 ` [PATCH v7 6/9] cgroup/cpuset: Make cpuset_attach_old_cs track task group leaders Waiman Long
2026-06-21 3:28 ` [PATCH v7 7/9] cgroup/cpuset: Move mpol_rebind_mm/cpuset_migrate_mm() calls inside cpuset_attach_task() Waiman Long
2026-06-22 2:48 ` Ridong Chen
2026-06-25 18:18 ` Waiman Long
2026-06-21 3:28 ` [PATCH v7 8/9] cgroup/cpuset: Support multiple source cpusets for cpuset_*attach() Waiman Long
2026-06-21 3:28 ` [PATCH v7 9/9] cgroup/cpuset: Support multiple destination " Waiman Long
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=ajqxRrhlglVqAeyu@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=atomlin@atomlin.com \
--cc=cgroups@vger.kernel.org \
--cc=david@kernel.org \
--cc=farhad.alemi@berkeley.edu \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=tj@kernel.org \
/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