From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 6E0F82DB794 for ; Sat, 18 Jul 2026 09:53:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784368388; cv=none; b=s2XK+52Ru5CazJthV3dZcd/tfaUme2IM4Ql4mHQemzGLJUt0ugrPhmSm4G1zW/YN63mDYtB2IH0yjpoHREloZPzN8Iun2lhEYWnOU7LtafGDPOXBTdxQFeeDp66B7H3+EZgAz197IWUV6MuLHnzY15t5bz3RLYCIpQHT3t5+6AE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784368388; c=relaxed/simple; bh=BynK+F/e8bHcEabJYUM5XBrZNmundeuFUhalgh8dE14=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=l4TL3ez8/bgPQD+e2DHJdO6kjg4MbAveuYGwocPlcSG+Y2izgrxk+xziH0qxTspDO5UDNV9NBmzzgSl2tshnTx8JtJgAILUoDc078agaQDU7mZoAHCJqY4ov0aBVawop5ZZNz2MXMZP1tP7XBlRz3Z26c9NiYWrVOZalqf8Cbvc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=gG/yb01a; arc=none smtp.client-ip=95.215.58.176 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) header.d=linux.dev header.i=@linux.dev header.b="gG/yb01a" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784368384; 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; bh=JIKVxJnOZClA0ZQyPpr1ULoxDrHsswe4PovGnm8FuOs=; b=gG/yb01aBUK7B5KNyAzLXAvjFCzWpFPC6nvhUluuobWVbluRxfEakjGs2cBX9uGaIuXSIp zhHEJHN9rLVBnUzSdatBdIOLVsuk//g6yUqC0z8zLr1sMiKF/r/TW81srFuqUBZ2Bz6YEQ 85EvOlhGNlbf81PNZNKtim/KI/uF/Dc= From: Guopeng Zhang To: Thomas Gleixner , Peter Zijlstra Cc: Frederic Weisbecker , linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH] cpu/hotplug: Prevent offlining the last domain housekeeping CPU Date: Sat, 18 Jul 2026 17:52:49 +0800 Message-ID: <20260718095249.1271870-1-guopeng.zhang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Guopeng Zhang _cpu_down() is supposed to leave at least one HK_TYPE_DOMAIN CPU online. However, cpumask_any_and() includes the CPU being offlined. The target therefore satisfies the check when it is the last online CPU in that housekeeping mask. Offlining it leaves no online CPU in the HK_TYPE_DOMAIN mask. The next scheduler-domain rebuild passes an empty span to build_sched_domains() and triggers its WARN_ON(). Use cpumask_any_and_but() to look for another online HK_TYPE_DOMAIN CPU and reject the offline request with -EBUSY if none exists. Testing: Tested on a 32-vCPU Ubuntu 24.04 guest with: isolcpus=domain,0,3-31 On the unpatched kernel, offlining the last HK_TYPE_DOMAIN CPU triggered a kernel panic. With this patch, the same operation was rejected with -EBUSY (errno 16), the target CPU remained online, and no scheduler-domain warning was observed. Fixes: de715325cc47 ("cpu: Revert "cpu/hotplug: Prevent self deadlock on CPU hot-unplug"") Signed-off-by: Guopeng Zhang --- kernel/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index b3c8553d7bd6..81e961964e59 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1418,8 +1418,9 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, * Keep at least one housekeeping cpu onlined to avoid generating * an empty sched_domain span. */ - if (cpumask_any_and(cpu_online_mask, - housekeeping_cpumask(HK_TYPE_DOMAIN)) >= nr_cpu_ids) { + if (cpumask_any_and_but(cpu_online_mask, + housekeeping_cpumask(HK_TYPE_DOMAIN), + cpu) >= nr_cpu_ids) { ret = -EBUSY; goto out; } -- 2.43.0