From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792785661; b=Am81n8+b9xPKXWWw2D7umkh+X1spYNMtC74TT8YT6m1QLEmXF/Wjeh5r4ZFeY9mTZoif TxQS5DcyeAg/gG/bSGQ0bXvlJL6CKgxdjqJlLzKKyxMP4bJTJnR99HnMGnMXq6Rl+Coow hR6BofRZHuIKkZddJscfafcEou6fH9F/b1B2PzyDxaJoJ024KWZgRvmyc6n2Qpow6luJ9 BMUiJly9kQFBTtwMmjZwju0VZLjZpw3A4WtwPKORG9L+Y4aX88lQ2z/PJHOfmSdihBK5r y7uR03PdUW5Z4p1f6Oz1jL6FLYw+ffdcNi8t6ybCPORwZgGy40heahSX8qTihf3SfIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792785661; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=3hEtCt1RpiFDvg9q07yX6m6YXcHmA6FTr+B0qJwNCZ8=; b=Db8DXiy0Oe7g/oNsUxkcbbzJlfbkBRPsdN/WFfxCHWiovKt1HyHIfZKm3y41aKA9mEAy paZrTNiDjfXUvQwiwjKCpkGeVexzqZhBqnqvDQHWWm+lv0wY+sJI04I+MgPZ+jafKW4P9 4ijMZHkCYhdeUpqoEpIXdezSlGpEmTmWsviXYQFAAsiOCgffV7z12HA2NdMs36GkPi5uM CwCWtuDPFRMuEqrMsvUI8uqLqeJTUrtdkqVgkwtJoiWAvUm7THwCZL7UrwOJ1obzT9UtU /SerGYLGTQgA6207W/4uuWtSPSBPMKBAzaAFY5lJR0yIV1N+Up2tBpxMvsVah2EFe4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YMO40bvB; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDFE5606A336 for ; Fri, 23 Oct 2026 20:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BDFE5606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YMO40bvB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792785660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3hEtCt1RpiFDvg9q07yX6m6YXcHmA6FTr+B0qJwNCZ8=; b=YMO40bvBtx3S6BTF8ZJPhJnj2yAIUwBahMHe1HRSqfPe2BxzWbWZGIYN7DNxLNHYJLjgZG /G2vewVM5qjWtjeNrIAT0RdGmTgWF8DaciVcV2y0/zdvlr5MO6i+POS3xSX8n+RbcmFHhP o4GwwH9W0TddH8SQbmGkxpNdH3/iSmw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-uNNf8CJsO6aIykFgthYORQ-1; Fri, 23 Oct 2026 16:00:56 -0400 X-MC-Unique: uNNf8CJsO6aIykFgthYORQ-1 X-Mimecast-MFC-AGG-ID: uNNf8CJsO6aIykFgthYORQ_1792785654 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCA6C195DE38; Fri, 23 Oct 2026 20:00:54 +0000 (UTC) Received: from llong-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4F2281955F24; Fri, 23 Oct 2026 20:00:53 +0000 (UTC) From: Waiman Long To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Guopeng Zhang , Waiman Long Subject: [PATCH-next v2 04/10] cgroup/cpuset: Minor fixes to prstate_housekeeping_conflict() Date: Fri, 23 Oct 2026 16:00:30 -0400 Message-ID: <20261023200036.60560-5-longman@redhat.com> In-Reply-To: <20261023200036.60560-1-longman@redhat.com> References: <20261023200036.60560-1-longman@redhat.com> 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Commit 9527ff78a413 ("cgroup/cpuset: Consider all the exclusive CPUs when doing housekeeping check") changes the way prstate_housekeeping_conflict() is being used by considering all the exclusive xcpus to be owned by the partition when doing housekeeping check. However there are two minor issues reported by sashiko with that patch: 1) In partition_cpus_change(), prstate_housekeeping_conflict() can be called with an invalid partition root. In that case, there are no isolated CPUs that are going to be returned back to the system to become housekeeping CPUs, so the calculation of the del_cpus cpumask is meaningless. 2) The checking of del_cpus in prstate_housekeeping_conflict() to see if it can contain an active housekeeping CPU that can be returned to the system ignores the fact that an active CPU not in HK_TYPE_DOMAIN_BOOT HK cpumask will not become an active housekeeping CPU when it is released by an isolated partition. Update the existing code to handle these two issues properly to make prstate_housekeeping_conflict() produce more accurate result. Fixes: 9527ff78a413 ("cgroup/cpuset: Consider all the exclusive CPUs when doing housekeeping check") Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 45 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 69fc02cd7469..5585d02ef0f8 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1397,6 +1397,9 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs, !cpumask_subset(new_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT))) return true; + if (del_cpus && cpumask_empty(del_cpus)) + del_cpus = NULL; + /* * Exit 2nd check early and return false if * 1) there is no boot time isolated nohz_full CPU @@ -1405,8 +1408,7 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs, * be returned back to the parent. */ if (!housekeeping_enabled(HK_TYPE_KERNEL_NOISE) || - (new_prs == parent_prs) || - ((new_prs == PRS_ROOT) && (!del_cpus || cpumask_empty(del_cpus)))) + (new_prs == parent_prs) || (!del_cpus && (new_prs == PRS_ROOT))) return false; /* @@ -1417,20 +1419,29 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs, if (parent_prs == PRS_ISOLATED) swap(new_cpus, del_cpus); - if (del_cpus && - (cpumask_first_and_and(del_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE), - cpu_active_mask) < nr_cpu_ids)) - return false; - if (!alloc_cpumask_var(&full_hk_cpus, GFP_KERNEL)) return true; + /* + * Check if del_cpus may contain a CPU that can become an active + * housekeeping CPU again. + */ + if (del_cpus) { + cpumask_and(full_hk_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE), + housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)); + if (cpumask_first_and_and(del_cpus, full_hk_cpus, + cpu_active_mask) < nr_cpu_ids) { + res = false; + goto out; + } + } + cpumask_and(full_hk_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE), housekeeping_cpumask(HK_TYPE_DOMAIN)); cpumask_andnot(full_hk_cpus, full_hk_cpus, isolated_cpus); cpumask_and(full_hk_cpus, full_hk_cpus, cpu_active_mask); res = !cpumask_weight_andnot(full_hk_cpus, new_cpus); - +out: free_cpumask_var(full_hk_cpus); return res; } @@ -2474,23 +2485,29 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs, struct tmpmasks *tmp) { enum prs_errcode prs_err; + int parent_prs = is_remote_partition(cs) + ? PRS_ROOT : parent_cs(cs)->partition_root_state; if (cs_is_member(cs)) return; prs_err = validate_partition(cs, trialcs); - if (!prs_err && !cpumask_empty(trialcs->effective_xcpus)) { + if (!prs_err && (parent_prs > 0) && + !cpumask_empty(trialcs->effective_xcpus)) { int prs = cs->partition_root_state; - int parent_prs = is_remote_partition(cs) - ? PRS_ROOT : parent_cs(cs)->partition_root_state; + /* * Check for housekeeping conflict by passing the whole * effective_xcpus as well as those CPUs that are to be * removed from cs as delmask. */ - cpumask_andnot(tmp->delmask, cs->effective_xcpus, trialcs->effective_xcpus); - if (parent_prs > 0 && - prstate_housekeeping_conflict(prs, parent_prs, + if (prs > 0) + cpumask_andnot(tmp->delmask, cs->effective_xcpus, + trialcs->effective_xcpus); + else + cpumask_clear(tmp->delmask); + + if (prstate_housekeeping_conflict(prs, parent_prs, trialcs->effective_xcpus, tmp->delmask)) prs_err = PERR_HKEEPING; } -- 2.56.0