From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D92F247281; Mon, 14 Apr 2025 13:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744637180; cv=none; b=fA9hr39lNgBcisZzdFEtJj0EHHCMqraOkDm5jFI/mxy25ud+ClYvmtpqzs8k1DFhCCONTWa7fSVfUJc8oM41sHD+SfR3nCA+d1HPfsA0yw6fw9RasYecLtlZtiNfbEEtm0imyMPrmuuV60uA1lDVAvXx8RkPF+ZtVjR+591gBLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744637180; c=relaxed/simple; bh=4aEI6CDGFpgHvtFi3lsTYpnDyZrFCuvFzrpoO3MmAoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sKUpHDaN+Wj4YgGo0rVjiOzFLM7P7czz2znlKBmn3oxlMaF+xUOHaTPMDVdxU5dH7tNR4iRfCsoPY20S5O8etEYu7sWihM9VoYHqG4YCAAfhDL8tjTeu7T3p5oyUjT5gk0l6fEMj/KVj2ZWV0cTFDY1lOuS3HAFZZlspe/qd+7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GpnEiNnA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GpnEiNnA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC83C4CEE9; Mon, 14 Apr 2025 13:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744637180; bh=4aEI6CDGFpgHvtFi3lsTYpnDyZrFCuvFzrpoO3MmAoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GpnEiNnAKxxY7Ln8fDGFLcjuEazv4azV7jasQ7RygRrC6Yzpm+SXa9jzGffvi5E+p gMyflxkxGKClPR3Vhn0tfXKDE7aBdBXms1zHKI6jKBX2vvXWYS39s1XLwKebjiH6xF uAxytyUfFqxd40C3wyj9wgIBR213H9DZJ9m5syikCrcF/Q+SxogKQ/TEfEAxQaOX5G 1B/GfRIriAsNJ+w8H7gvthFhtd9Zo2PBifdI3XXIq+rFlFzGcr4zist1T5A+ZK9AoS 19hx9cg5oIUaECcL/NOUhd6UhXNvZXEs0l1olGqgEYc5iDn0f7xp03a0ktGw/9J9Fi aVORHagKsVedw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Waiman Long , Tejun Heo , Sasha Levin , hannes@cmpxchg.org, mkoutny@suse.com, cgroups@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 04/34] cgroup/cpuset: Don't allow creation of local partition over a remote one Date: Mon, 14 Apr 2025 09:25:40 -0400 Message-Id: <20250414132610.677644-4-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250414132610.677644-1-sashal@kernel.org> References: <20250414132610.677644-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.2 Content-Transfer-Encoding: 8bit From: Waiman Long [ Upstream commit 6da580ec656a5ed135db2cdf574b47635611a4d7 ] Currently, we don't allow the creation of a remote partition underneath another local or remote partition. However, it is currently possible to create a new local partition with an existing remote partition underneath it if top_cpuset is the parent. However, the current cpuset code does not set the effective exclusive CPUs correctly to account for those that are taken by the remote partition. Changing the code to properly account for those remote partition CPUs under all possible circumstances can be complex. It is much easier to not allow such a configuration which is not that useful. So forbid that by making sure that exclusive_cpus mask doesn't overlap with subpartitions_cpus and invalidate the partition if that happens. Signed-off-by: Waiman Long Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/cpuset-internal.h | 1 + kernel/cgroup/cpuset.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h index 976a8bc3ff603..383963e28ac69 100644 --- a/kernel/cgroup/cpuset-internal.h +++ b/kernel/cgroup/cpuset-internal.h @@ -33,6 +33,7 @@ enum prs_errcode { PERR_CPUSEMPTY, PERR_HKEEPING, PERR_ACCESS, + PERR_REMOTE, }; /* bits in struct cpuset flags field */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1892dc8cd2119..df58760be03ad 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -62,6 +62,7 @@ static const char * const perr_strings[] = { [PERR_CPUSEMPTY] = "cpuset.cpus and cpuset.cpus.exclusive are empty", [PERR_HKEEPING] = "partition config conflicts with housekeeping setup", [PERR_ACCESS] = "Enable partition not permitted", + [PERR_REMOTE] = "Have remote partition underneath", }; /* @@ -2830,6 +2831,19 @@ static int update_prstate(struct cpuset *cs, int new_prs) goto out; } + /* + * We don't support the creation of a new local partition with + * a remote partition underneath it. This unsupported + * setting can happen only if parent is the top_cpuset because + * a remote partition cannot be created underneath an existing + * local or remote partition. + */ + if ((parent == &top_cpuset) && + cpumask_intersects(cs->exclusive_cpus, subpartitions_cpus)) { + err = PERR_REMOTE; + goto out; + } + /* * If parent is valid partition, enable local partiion. * Otherwise, enable a remote partition. -- 2.39.5