From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E986B3806B4 for ; Wed, 24 Jun 2026 15:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782315933; cv=none; b=WzjujCgiHs2S463R7aI872lMb5hyj+Ef/sz5EbFi3TNDGZeicvarxDkn+6lGQoxE5eyOz1c0fb/uhWd2c+Z6DM5SgG9CXxFAS/ercDMHnzOTPYd+zSywuLVxXcIgYdxnXFmdDPCYwn9qeQXionbLBIU3w7oMw24mIxNOXO2+44s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782315933; c=relaxed/simple; bh=RAgF1FFgNlfrdTEPiMpeZp2hIOVJKZIIQ2OLT1gYqKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p3pXpEYcHKhGDsZyHDFW2ChwcK5/A1ZClhEKF1uJwDoeatdUG0ZoBSgsQNH4+EJ1nrMzFJfhldjgWAcaNIzDydx3VSzCf+1NaRb/KjH1KZk5Rfo682DscVoVSGz08Uv+06k3WcomDE1pZBzyfoB+C8bk/2HlRKXkb500gX5qEao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=PC4XpCk9; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="PC4XpCk9" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-492329c5514so5101145e9.1 for ; Wed, 24 Jun 2026 08:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1782315930; x=1782920730; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qZ7EIwRMMtpttBcQvtyW0LvRDRIObg2LOmo61ZATMkk=; b=PC4XpCk9ZdgAHBuZmiVPyzVa4otR1zjUYRDHtlAkdlMIPD19zg5U86gPApNbveseXM WrPLBuRWMvbjMIT06IEOXF0r4oUp2VjWSZOl9k7ugiYecEyru0YFSyeifGMQRMPnkXqr YZcPfo7ZvRVf9qAwDI65JZy/0b7CwaETeic6vsxBNPSc1QgaYA+GxR5q6W63kT872etx 4an3UMeoNfoxcXoUC6bdM7XfAruu+vYXCxcuIdUQB2B/ErhR6GuJ0ThKKJioyWkmCpcJ Ou1S+qZ2NT+S9vz1EcTGQiyHaJ1egKPPWm0FyCmZP8Jsq82aFO95auiyvd26P+WNFJNT Yp+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782315930; x=1782920730; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qZ7EIwRMMtpttBcQvtyW0LvRDRIObg2LOmo61ZATMkk=; b=TmWek8cwGaZ6FizEUXOmwoLH6PHm5h4IuILLVuuEJD9JtijrWYAS6mRjnunC6Tdndf 09tP3wqMRWJx6ldd4bqAfzJ5ipL7VC0w6/DvyfEX6hVB2BEoIqIZJWq6AQ5uPOREyqv9 QcrH+FqCWa/9XEbAVv6DqV9mBFhVsWp6HiIMGZgRDgMHMZlW8Jp8VR2USQqB5W1J3HKJ SJFn/NRjqg+x4sLujHPsNfBrRr9QlPihc+R8qGfjfCKVg0SFxRtJciA8ui/Smj/xZ57g 5SWzyU8I4NRZ+xxdkuwmWm3/LDFW4r0jtaoI+H9TqHmp9FNOcotHt6tOM0eRZSmUdPIO IQQg== X-Forwarded-Encrypted: i=1; AFNElJ9W4ABnEHMy5BWTDxkOakqjWo9OiYJEB/Wjzp/Tr/BPMV18klMt9unn5WjCGd/0/NhmX3ZHJX9ZEJTnbOk=@vger.kernel.org X-Gm-Message-State: AOJu0YwJtWIhiASsakatQO/J69jSqJ/a/Odlg5+HmypqopseupZmZDM0 uc/xKWiL7+Kdi7a3zkFsDmTAKQnYJm7wk7GGD4bBP+Z7E0M8tGQapXef4uWwcx+gpmw= X-Gm-Gg: AfdE7cmqUG0DKTUIK0kNrItGRPC1V7kQfOs3nkPRYIbRle/W6pNxftEPpBbWdYlD08u mB1TmQTpaUVjg2EMgWUFP++LTi4F/tRUFr5y7LVkFjINO0n7CClTZYhsfShYyi5FXp70p1iERb/ 2Mg6D/xiLm970yuMYLKYGQKYFiveIe/rwWMMOl9uDCOgYd7+ZuvV5pZEAtw8PPud0OhMCwi9L2h s8Hq4xGNd6QKI4LrABxDCVji14uegEcnL9pdeCKek9wT37KXRUZVrfEDRbJXcX4WGRdceADBc0h C3r3k1mQ5TBqFj1XiJV2RtjXHTtIdLRlyc0Onw05Dzav7lg6HdV+P4myQFzJF0lCBHIR3zoFX4r DIr+AodsSjRNObWRMUKlm9IIiPl+LhNr8L5iq1NEkvAprm0xWMucsO5UqExwpn8QFKEbr935BjS m+T5SG/5icKtSBtCn86w== X-Received: by 2002:a05:600c:3111:b0:492:38c9:b265 with SMTP id 5b1f17b1804b1-492632b6ef8mr14978345e9.15.1782315930241; Wed, 24 Jun 2026 08:45:30 -0700 (PDT) Received: from localhost.localdomain ([62.77.90.70]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926403573csm1307185e9.7.2026.06.24.08.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 08:45:29 -0700 (PDT) Date: Wed, 24 Jun 2026 17:45:27 +0200 From: Michal =?utf-8?Q?Koutn=C3=BD?= To: Waiman Long Cc: Chen Ridong , Tejun Heo , Johannes Weiner , Peter Zijlstra , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Aaron Tomlin , Guopeng Zhang Subject: Re: [PATCH-next v5 6/6] cgroup/cpuset: Support multiple source/destination cpusets for cpuset_*attach() Message-ID: References: <20260602023203.248077-1-longman@redhat.com> <20260602023203.248077-7-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="itlyjlmnqgc2pen7" Content-Disposition: inline In-Reply-To: <20260602023203.248077-7-longman@redhat.com> --itlyjlmnqgc2pen7 Content-Type: text/plain; protected-headers=v1; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH-next v5 6/6] cgroup/cpuset: Support multiple source/destination cpusets for cpuset_*attach() MIME-Version: 1.0 Hello Waiman. On Mon, Jun 01, 2026 at 10:32:03PM -0400, Waiman Long = wrote: > This problem is less an issue when enabling the cpuset controller as all > the newly created child cpusets will have exactly the same set of CPUs > and memory nodes except when deadline tasks are involved in migration > as the deadline task accounting data can be off. >=20 > It can be more problematic when the cpuset controller is disabled as > their set of CPUs and memory nodes may differ from their parent or with > the moving of multi-threaded process from different threaded cgroups. When I generalize that it can be an issue for any threaded controller that somehow relies on the _difference_ between old and new thread membership. So I checked some: pids and perf_events look alright (no diff-dependency) but I noticed the very same issue is tackled in sched_change_group/scx_cgroup_move_task and that there is a member inside task_struct allocated for this state tracking already: task_struct::scx::cgrp_moving_from > Fix that by tracking the set of source (old) and destination cpusets > in singly linked lists and iterating them all to properly update the > internal data. Also keep the current cs and oldcs variables up-to-date > with the css and task iterators. So there would be more than a single use for something conceptually like: diff --git a/include/linux/sched.h b/include/linux/sched.h index 004e6d56a499a..740c02f220c75 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1326,6 +1326,9 @@ struct task_struct { #ifdef CONFIG_PREEMPT_RT struct llist_node cg_dead_lnode; #endif /* CONFIG_PREEMPT_RT */ +#ifdef CONFIG_CGROUPS_MOVING_FROM + struct cgroup *cgrp_moving_from; +#endif #endif /* CONFIG_CGROUPS */ #ifdef CONFIG_X86_CPU_RESCTRL u32 closid; diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index 1a3af2ea2a794..5b63afe83f333 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -240,9 +240,6 @@ struct sched_ext_entity { bool disallow; /* reject switching into SC= X */ =20 /* cold fields */ -#ifdef CONFIG_EXT_GROUP_SCHED - struct cgroup *cgrp_moving_from; -#endif struct list_head tasks_node; }; =20 diff --git a/init/Kconfig b/init/Kconfig index 2937c4d308aec..d7e7d4477f862 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1186,6 +1186,7 @@ config EXT_GROUP_SCHED depends on SCHED_CLASS_EXT && CGROUP_SCHED select GROUP_SCHED_WEIGHT select GROUP_SCHED_BANDWIDTH + select CGROUPS_MOVING_FROM default y =20 endif #CGROUP_SCHED @@ -1288,6 +1289,7 @@ config CPUSETS depends on SMP select UNION_FIND select CPU_ISOLATION + select CGROUPS_MOVING_FROM help This option will let you create and manage CPUSETs which allow dynamically partitioning a system into sets of CPUs and I think this could simplify the before-after state tracking generally, WDYT? Michal --itlyjlmnqgc2pen7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iJEEABYKADkWIQRCE24Fn/AcRjnLivR+PQLnlNv4CAUCajv7kRsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMiwyLDIACgkQfj0C55Tb+AgcJwD/bg/SvG8VumQlUebbvHIr L1N7bJj/7LlKGZ3dYy8NebAA/itwcBWrkx3By3y8dBJOz4d5knPVRBXHIh5DGkHT P9wN =N/q4 -----END PGP SIGNATURE----- --itlyjlmnqgc2pen7--