From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.122 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796457076; b=lrIMoai4POWs6SN8+1Xg4BTouvRl65fSxQ795GzkCX1jCzqh9qW7mkq5gGCib2sRAiYf FNgo1xIU9IoFO2Z+ZzNqOQQeqX8/8k/WjozpG7+kGGr3hyY+YAzr9YsrwI9g4EJjhiR86 3z2PYo/+ctb9jIsAECcIMRNA9B4jr6CG/ewCrwV1k7xnP/zjb2cBh0gPtPtL085WseYiQ lhGgrJ7ItkxangoaIxf2wNUPrRHZi2+WCGmJM8ZoFbx/dZZ/DEHssX2nhEvPBZ8Gq1E8Y nBoAfYNUheBGrjZzRDFp42De5pHpt2nsNWyMs5uv5TQQ2xK7Qma/cwQZC13ZDLcAQeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796457076; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=6wJL35YOfxjdUdfEnIVaUC3hcPAbi9910jDnLjJ3Fsw=; b=muPiedrQUjVvTTQefO1ltzu229ygc0Dsnz0508mzGJwamu2mC3rSll90eLcCPjX/KA+l WHKWozwDfjTmGLNZkJofptdGx5ZBBymkgWRDqXs62g2qi52u5kcSy5hia/sgwmjmfosfa cPdBgEECV5R38qj4tVzD7gyMR61UmciqP8n/l7gcn+64YYeCVzDdLvMHCKxfNIrU4qdXu 8Tg57nxXkcKEPw+hr6c0J8Fr36mh3bG35pcOxYGAoK7fagI/dKiR0YuInNa9hXX3H8B1r e9f8INjhuXx/tPbcD925D37XEXfir4K6Ia9FjFXB3RCTfe6PZQ1rPxOPG2RoLEzuHjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ZzFgkMVI; arc=none smtp.remote-ip=95.215.58.122 Received: from mta1.migadu.com (out-122.mta1.migadu.com [95.215.58.122]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EADE606A32F for ; Sat, 5 Dec 2026 07:51:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0EADE606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ZzFgkMVI X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=rU5uPEWfGZYRi64OnVZyAk6AN88HYBAwCRKQY4KXKT8=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796457071; v=1; x=1797061871; b=ZzFgkMVIpsZERcSGpknrzXouKBGRudWy2fmOML737dtiUgfS6Y7a3zkkuJLfLE9qNYLheltb oOiH7jEYJ3oS7KeIyg1drXqT7IYs2gInLxfUw1CXJb3W0lsTf75lTLp52kd2fKTT9pO9HeoFPDN lAxpXizPbVlnuEnDOorvT0M4= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a3fbb78bd9a28477; Sat, 05 Dec 2026 07:51:10 +0000 X-Mizu-Trace-ID: a3fbb78bd9a28477 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Sat, 5 Dec 2026 15:51:03 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 07/12] cpuset: introduce validate_local_partition() To: Ridong Chen , Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Ridong Chen References: <20261129024431.2485721-1-ridong.chen@linux.dev> <20261129024431.2485721-8-ridong.chen@linux.dev> Content-Language: en-US From: Guopeng Zhang In-Reply-To: <20261129024431.2485721-8-ridong.chen@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 2026/11/29 10:44, Ridong Chen 写道: > From: Ridong Chen > > Add validate_local_partition() to check the requirements of a local > partition in one place, so that local partition enablement and update > can share it: > > 1. The parent must be a valid partition root, otherwise PERR_INVPARENT > or PERR_NOTPART is returned. > 2. If both cpuset.cpus and cpuset.cpus.exclusive are empty, return > PERR_CPUSEMPTY rather than reporting an invalid cpu list. > 3. A root partition is not allowed under an isolated parent. > 4. Optionally, the user exclusive CPUs must not overlap with any > sibling. A valid partition has passed this check already, so it is > only needed when an invalid partition is to become valid again. > 5. validate_partition() for the common checks, including the > housekeeping conflict and tasks_nocpu_error() checks. > > It is marked __maybe_unused until local_partition_enable() starts to > use it in the next patch. > > Signed-off-by: Ridong Chen > --- > kernel/cgroup/cpuset.c | 61 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index 39d5b56f14b0..a3b3a3fe63ff 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -1989,6 +1989,67 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus, > partition_disable(cs, -prs, cs->prs_err, tmp); > } > > +static bool is_user_xcpus_exclusive(struct cpuset *cs) > +{ > + struct cpuset *parent = parent_cs(cs); > + struct cgroup_subsys_state *css; > + struct cpuset *child; > + bool exclusive = true; > + > + rcu_read_lock(); > + cpuset_for_each_child(child, css, parent) { > + if (child == cs) > + continue; > + if (!cpusets_are_exclusive(cs, child)) { > + exclusive = false; > + break; > + } > + } > + rcu_read_unlock(); > + return exclusive; > +} > + > +/** > + * validate_local_partition - Validate for local partition > + * @cs: Target cpuset to validate > + * @new_prs: New partition root state to validate > + * @excpus: New effective exclusive CPUs mask to validate > + * @excl_check: Flag to enable exclusive CPUs ownership validation > + * @tmp: Temporary masks > + * > + * Return: PERR_NONE if validation passes, appropriate error code otherwise > + * > + * Important: The caller must ensure that @cs's cpu mask is updated before > + * invoking this function when exclusive CPU validation is required. > + */ > +static enum prs_errcode __maybe_unused > +validate_local_partition(struct cpuset *cs, int new_prs, > + struct cpumask *excpus, bool excl_check, > + struct tmpmasks *tmp) > +{ > + struct cpuset *parent = parent_cs(cs); > + > + /* The parent must be a partition root */ > + if (!is_partition_valid(parent)) { > + return is_partition_invalid(parent) > + ? PERR_INVPARENT : PERR_NOTPART; > + } > + > + /* Report the empty user cpumasks instead of an invalid cpu list */ > + if (cpumask_empty(excpus) && xcpus_empty(cs)) > + return PERR_CPUSEMPTY; > + > + /* A root partition is not allowed under an isolated parent */ > + if (new_prs == PRS_ROOT && parent->partition_root_state == PRS_ISOLATED) > + return PERR_ISOPARENT; > + > + if (excl_check && !is_user_xcpus_exclusive(cs)) > + return PERR_NOTEXCL; > + > + return validate_partition(cs, parent, new_prs, excpus, > + tmp ? tmp->delmask : NULL); Hi Ridong, I noticed that in this series, the last argument of validate_local_partition() is NULL in the enable path and tmp in the update path. When tmp is non-NULL, the function only uses tmp->delmask. Would it make sense to take a struct cpumask *delmask directly instead of struct tmpmasks *tmp? The enable path could still pass NULL, while the update path could pass tmp->delmask directly. Would this make the interface clearer about which CPU mask is actually needed? Thanks, Guopeng > +} > + > /** > * update_parent_effective_cpumask - update effective_cpus mask of parent cpuset > * @cs: The cpuset that requests change in partition root state