From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5543837C918 for ; Tue, 21 Apr 2026 03:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740860; cv=none; b=U2tk7cjR79hnDGuTOsjvMTyO8QoCn6QtLrXUExi2OffklaN3Qf7t1DfIS/62aLuYa8EVcW90ZyRiPwvR0MrNXfS32bpo33jliW0i/NlXpVojXh04vaf79MHfEWerX0cE8LF+CRuGRcvQsJynuPnKGG3jY58RdWmfqz19tSOYrXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740860; c=relaxed/simple; bh=KY9RWTeYpkME766HcWMc5adAT4G/1XXfate7fAfO6ps=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lmx1dD89UrIFeSVrrBFSWtIwq3rmgVGwaYKqOw8KljmFoZuXf6xniXlthfsaX4ZhtJ2pVqpLK9geQiRtqj87URPLTsK5fdcerzuCqHt0UGhL0VuhSDsfkMppRuxCLPtuWg9sPPVi02r+4qHFmf1n+q8ToeJWIDLWs8aZbHHW4hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gXOgwQmj; arc=none smtp.client-ip=170.10.129.124 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) header.d=redhat.com header.i=@redhat.com header.b="gXOgwQmj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776740858; 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=5PuhRkn96CiNoOus+r7NzZUWwV4LXmvzWiP5TcnJ3DQ=; b=gXOgwQmj4n1rrxFMWlnsjKi57vP7sscxAmtpJ1mnL9veTj0Zu3ZFMdZ/gYFJIouX1ogdcW GFrv+/K2eTjUMHnmsPkwa0VzmHg0faFw9pTf/LP0cLeFzEelZKLXBtFHmhIQPgBc8LVGWD vKGpmKLT3FGLZ6w3GAkRpiNyh7AEnsY= 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-693-vlbhX3RZO5W5EvKJ9lg_wg-1; Mon, 20 Apr 2026 23:07:34 -0400 X-MC-Unique: vlbhX3RZO5W5EvKJ9lg_wg-1 X-Mimecast-MFC-AGG-ID: vlbhX3RZO5W5EvKJ9lg_wg_1776740849 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 2586F195608B; Tue, 21 Apr 2026 03:07:29 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.65.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A8FA19560AB; Tue, 21 Apr 2026 03:07:21 +0000 (UTC) From: Waiman Long To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Guenter Roeck , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Chen Ridong , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-hwmon@vger.kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Costa Shulyupin , Qiliang Yuan , Waiman Long Subject: [PATCH 21/23] cgroup/cpuset: Limit the side effect of using CPU hotplug on isolated partition Date: Mon, 20 Apr 2026 23:03:49 -0400 Message-ID: <20260421030351.281436-22-longman@redhat.com> In-Reply-To: <20260421030351.281436-1-longman@redhat.com> References: <20260421030351.281436-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 CPU hotplug is used to facilitate the modification of the HK_TYPE_KERNEL_NOISE and HK_TYPE_MANAGED_IRQ cpumasks. However, tearing down and bringing up CPUs can impact the cpuset partition states as well. For instance, tearing down the last CPU of a partition can invalidate the partition with active tasks which will not happen if CPU hotplug isn't used. A workaround of this issue is disable the invalidation by pretending that the partition has no task, and making the tasks within the partition to the effective CPUs of its parent for a short while during the short transition process where the CPUs will be teared down and the brought up again. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index a927b9cd4f71..5f6b4e67748f 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -434,6 +434,13 @@ static inline bool partition_is_populated(struct cpuset *cs, struct cpuset *cp; struct cgroup_subsys_state *pos_css; + /* + * Hack: In cpuhp_offline_cb_mode, pretend all partitions are empty + * to prevent unnecessary partition invalidation. + */ + if (cpuhp_offline_cb_mode) + return false; + /* * We cannot call cs_is_populated(cs) directly, as * nr_populated_domain_children may include populated @@ -3881,6 +3888,17 @@ hotplug_update_tasks(struct cpuset *cs, cs->effective_mems = *new_mems; spin_unlock_irq(&callback_lock); + /* + * When cpuhp_offline_cb_mode is active, valid isolated partition + * with tasks may have no online CPUs available for a short while. + * In that case, we fall back to parent's effective CPUs temporarily + * which will be reset back to their rightful value once the affected + * CPUs are online again. + */ + if (cpuhp_offline_cb_mode && cpumask_empty(new_cpus) && + (cs->partition_root_state == PRS_ISOLATED)) + cpumask_copy(new_cpus, parent_cs(cs)->effective_cpus); + if (cpus_updated) cpuset_update_tasks_cpumask(cs, new_cpus); if (mems_updated) -- 2.53.0