Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: "Ridong Chen" <ridong.chen@linux.dev>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Guopeng Zhang" <guopeng.zhang@linux.dev>
Subject: Re: [PATCH-next v10 10/11] cgroup/cpuset: Support multiple destination cpusets for cpuset_*attach()
Date: Thu, 9 Jul 2026 23:48:02 -0400	[thread overview]
Message-ID: <e117b3e9-3973-40de-8976-eb0ebef18c4c@redhat.com> (raw)
In-Reply-To: <e254af713b5345aec3d086771ecf1e71@kernel.org>

On 7/6/26 8:57 PM, Tejun Heo wrote:
> Hello, Waiman.
>
> On Thu, Jul 02, 2026 at 05:47:56PM -0400, Waiman Long wrote:
>> It is assumed that a given cpuset cannot be both a source and a
>> destination cpuset. [...] it will print a warning and fail the attach
>> operation in these unexpected cases [...]
> This assumption doesn't hold - the WARN_ON_ONCE() and -EINVAL fire on a
> legitimate migration. It's the case sashiko flagged, and it does reach
> can_attach().
>
> Threaded subtree with partial cpuset delegation:
>
>    P (+cpuset)
>    |- R (cpuset)        <- destination
>    |  `- C (no cpuset)  -> effective cpuset == R
>    `- W (cpuset)
>
> Group leader in R, thread_a in C, thread_b in W; migrate the whole
> process into R (echo $PID > R/cgroup.procs). thread_a moves C->R: its
> cgroup changes so compare_css_sets() keeps it in the taskset, but its
> cpuset css is unchanged (C inherits R's), so task_cs() == cs == R. cpuset
> is in ss_mask because thread_b (W->R) changed. can_attach() then tags R
> as a source (thread_a) and the destination (thread_b):
>
>    WARNING: kernel/cgroup/cpuset.c:3054 at cpuset_can_attach_check+0xcd/0x130
>     cpuset_can_attach+0x131/0x2f0
>     cgroup_migrate_execute+0x367/0x450
>    cgroup.procs write returns -EINVAL
>
> So a thread already in the destination's effective cpuset does show up in
> the iteration when it reaches that cpuset through a different, non-cpuset
> child - compare_css_sets() keys on the cgroup, not the cpuset css.
>
> 1-9 handle this correctly (the migration succeeds); the patch 10 guard
> regresses it. I've taken 1-9 into for-7.3 - please respin 10-11. One
> option: when oldcs == cs the pair is a cpuset no-op, so skip it and add
> it to neither list.

Sorry for the late reply. I was offline for a few days because my labtop 
SSD was having problem.

Yes, I realize that my assumption about oldcs != cs is incorrect. I will 
revise the remaining patch to address the issue.

Thanks,
Longman


  reply	other threads:[~2026-07-10  3:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 21:47 [PATCH-next v10 00/11] cgroup/cpuset: Support multiple source/destination cpusets for cpuset_*attach() Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 01/11] cgroup/cpuset: Make nr_deadline_tasks an atomic_t Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 02/11] cgroup/cpuset: Fix node inconsistencies between cpuset_update_tasks_nodemask() and cpuset_attach() Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 03/11] cgroup/cpuset: Prevent race between task attach and cpuset state change Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 04/11] cgroup/cpuset: Put all task attach related variables into attach_ctx Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 05/11] cgroup/cpuset: Add a cpuset_reserve_dl_bw() helper Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 06/11] cgroup/cpuset: Expand the scope of cpuset_can_attach_check() Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 07/11] cgroup/cpuset: Make attach_ctx.old_cs track task group leader Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 08/11] cgroup/cpuset: Move mpol_rebind_mm/cpuset_migrate_mm() calls inside cpuset_attach_task() Waiman Long
2026-07-02 21:47 ` [PATCH-next v10 09/11] cgroup/cpuset: Support multiple source cpusets for cpuset_*attach() Waiman Long
2026-07-03  2:20   ` Ridong Chen
2026-07-02 21:47 ` [PATCH-next v10 10/11] cgroup/cpuset: Support multiple destination " Waiman Long
2026-07-03  3:31   ` Ridong Chen
2026-07-03  5:56     ` Waiman Long
2026-07-07  0:57   ` Tejun Heo
2026-07-10  3:48     ` Waiman Long [this message]
2026-07-02 21:47 ` [PATCH-next v10 11/11] selftests/cgroup: Add test for cpuset affinity on controller disable Waiman Long
2026-07-07  7:15 ` [PATCH-next v10 00/11] cgroup/cpuset: Support multiple source/destination cpusets for cpuset_*attach() Tejun Heo

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=e117b3e9-3973-40de-8976-eb0ebef18c4c@redhat.com \
    --to=longman@redhat.com \
    --cc=atomlin@atomlin.com \
    --cc=cgroups@vger.kernel.org \
    --cc=guopeng.zhang@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --cc=shuah@kernel.org \
    --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