From: Tejun Heo <tj@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
Zefan Li <lizefan.x@bytedance.com>,
Johannes Weiner <hannes@cmpxchg.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] cgroup/cpuset: Keep current cpus list if cpus affinity was explicitly set
Date: Thu, 28 Jul 2022 07:23:07 -1000 [thread overview]
Message-ID: <YuLF+xXaCzwWi2BR@slm.duckdns.org> (raw)
In-Reply-To: <20220728005815.1715522-1-longman@redhat.com>
Hello,
On Wed, Jul 27, 2022 at 08:58:14PM -0400, Waiman Long wrote:
> It was found that any change to the current cpuset hierarchy may reset
> the cpus_allowed list of the tasks in the affected cpusets to the
> default cpuset value even if those tasks have cpus affinity explicitly
> set by the users before. That is especially easy to trigger under a
> cgroup v2 environment where writing "+cpuset" to the root cgroup's
> cgroup.subtree_control file will reset the cpus affinity of all the
> processes in the system.
>
> That is especially problematic in a nohz_full environment where the
> tasks running in the nohz_full CPUs usually have their cpus affinity
> explicitly set and will behave incorrectly if cpus affinity changes.
>
> Fix this problem by adding a flag in the task structure to indicate that
> a task has their cpus affinity explicitly set before and make cpuset
> code not to change their cpus_allowed list unless the user chosen cpu
> list is no longer a subset of the cpus_allowed list of the cpuset itself.
>
> With that change in place, it was verified that tasks that have its
> cpus affinity explicitly set will not be affected by changes made to
> the v2 cgroup.subtree_control files.
I think the underlying cause here is cpuset overwriting the cpumask the user
configured but that's a longer discussion.
> +/*
> + * Don't change the cpus_allowed list if cpus affinity has been explicitly
> + * set before unless the current cpu list is not a subset of the new cpu list.
> + */
> +static int cpuset_set_cpus_allowed_ptr(struct task_struct *p,
> + const struct cpumask *new_mask)
> +{
> + if (p->cpus_affinity_set && cpumask_subset(p->cpus_ptr, new_mask))
> + return 0;
> +
> + p->cpus_affinity_set = 0;
> + return set_cpus_allowed_ptr(p, new_mask);
> +}
I wonder whether the more predictable behavior would be always not resetting
the cpumask if it's a subset of the new_mask. Also, shouldn't this check
p->cpus_mask instead of p->cpus_ptr?
Thanks.
--
tejun
next prev parent reply other threads:[~2022-07-28 17:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 0:58 [PATCH 1/2] cgroup/cpuset: Keep current cpus list if cpus affinity was explicitly set Waiman Long
2022-07-28 0:58 ` [PATCH 2/2] cgroup: Skip subtree root in cgroup_update_dfl_csses() Waiman Long
2022-07-28 14:44 ` Michal Koutný
2022-07-28 14:49 ` Waiman Long
2022-07-28 17:26 ` Tejun Heo
2022-07-28 17:27 ` Tejun Heo
2022-07-28 14:44 ` [PATCH 1/2] cgroup/cpuset: Keep current cpus list if cpus affinity was explicitly set Michal Koutný
2022-07-28 14:59 ` Waiman Long
2022-07-28 15:23 ` Michal Koutný
2022-07-28 15:35 ` Waiman Long
2022-07-28 16:50 ` Valentin Schneider
2022-07-28 17:42 ` Waiman Long
2022-07-28 17:23 ` Tejun Heo [this message]
2022-07-28 18:57 ` Waiman Long
2022-07-28 19:02 ` Tejun Heo
2022-07-28 19:21 ` Waiman Long
2022-07-28 20:44 ` Tejun Heo
2022-07-28 21:04 ` Waiman Long
2022-07-28 21:39 ` Tejun Heo
2022-07-29 14:15 ` Valentin Schneider
2022-07-29 14:50 ` Waiman Long
2022-07-29 18:31 ` 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=YuLF+xXaCzwWi2BR@slm.duckdns.org \
--to=tj@kernel.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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