mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Chen Ridong <chenridong@huaweicloud.com>
Cc: longman@redhat.com, tj@kernel.org, hannes@cmpxchg.org,
	mkoutny@suse.com, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org, lujialin4@huawei.com,
	chenridong@huawei.com
Subject: Re: [PATCH next] cpuset: fix warning when attaching tasks with offline CPUs
Date: Mon, 14 Jul 2025 13:59:15 +0200	[thread overview]
Message-ID: <20250714115915.GU905792@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <090bd627-95dc-49ef-a4f6-d78d8f6d6cec@huaweicloud.com>

On Mon, Jul 14, 2025 at 07:30:39PM +0800, Chen Ridong wrote:

> >> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> >> index f74d04429a29..5401adbdffa6 100644
> >> --- a/kernel/cgroup/cpuset.c
> >> +++ b/kernel/cgroup/cpuset.c
> >> @@ -3121,7 +3121,7 @@ static void cpuset_attach_task(struct cpuset *cs, struct task_struct *task)
> >>  	if (cs != &top_cpuset)
> >>  		guarantee_active_cpus(task, cpus_attach);
> >>  	else
> >> -		cpumask_andnot(cpus_attach, task_cpu_possible_mask(task),
> >> +		cpumask_andnot(cpus_attach, cpu_active_mask,
> >>  			       subpartitions_cpus);
> > 
> > This breaks things. Any task mask must be a subset of
> > task_cpu_possible_mask() at all times. It might not be able to run
> > outside of that mask.
> 
> Hi Peter,
> 
> Thanks for your feedback. I'm afraid I don't fully understand what you
> mean by "breaks things".  Could you please explain in more detail?
> 
> To clarify my current understanding: this patch simply changes the
> cpus_attach initialization from task_cpu_possible_mask(task) to
> cpu_active_mask. The intention is that when CPUs are offlined and
> tasks get migrated to root cpuset, we shouldn't try to migrate tasks
> to offline CPUs. And since cpu_active_mask is a subset of
> cpu_possible_mask, I thought this would be safe. Did I miss anything?

task_cpu_possible_mask() is the mask a task *MUST* stay inside of.

Specifically, this was introduced for ARMv9 where some CPUs drop the
capability to run ARM32 instructions. Trying to schedule an ARM32 task
on a CPU that does not support that instruction set is an immediate and
fatal fail.

Your change results in in something akin to:

  set_cpus_allowed_task(task, cpu_active_mask & ~subpartition_cpus);

Which does not honor the task_cpu_possible_mask() constraint.

  reply	other threads:[~2025-07-14 11:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14  3:23 Chen Ridong
2025-07-14  8:41 ` Peter Zijlstra
2025-07-14 11:30   ` Chen Ridong
2025-07-14 11:59     ` Peter Zijlstra [this message]
2025-07-15  2:29       ` Chen Ridong
2025-07-14 19:46 ` Waiman Long
2025-07-15  2:31   ` Chen Ridong

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=20250714115915.GU905792@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huawei.com \
    --cc=chenridong@huaweicloud.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=lujialin4@huawei.com \
    --cc=mkoutny@suse.com \
    --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

all inboxes | Powered by JetHome®