From nobody Fri Oct 3 15:35:59 2025 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 7DDC032A3E9 for ; Fri, 29 Aug 2025 15:48:28 +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=1756482508; cv=none; b=BcldlwzUEsRQPDgmgK9JQA1rTgNAggwCNq9n3xMREp7hZaxi4yY43OXZPHiHuzprPHks1vc5xIz1i9TW2688kRPtCPETZwITk4aPvmCaRz8ZIh8MDbGIsM3K5xhSVybRNiNi+PPOAC07Zh2DV5UKtIpG5LOjl0gc+eX47ozRKrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756482508; c=relaxed/simple; bh=bjPVH71yYHRT38x+a2qhkcGYmz0Liwe3xJMHVBXj3C4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aHwd5Cm6Im09svjhitutE8d5gjfauwztcKDaFCDBrydNKANq36e/Ich6qDcnJgdpbP8NA/eZkf4+1t7H5x/uPGEHyULTlSwrmlPmk0X9oTYnE7rcCF/NZ6dCt6JaXQmi10/gKAtt6FTN1M8DYqHVAkQstJfoWTC5JSoQODwr+VM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T4GMj8XN; 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="T4GMj8XN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36AFDC4CEF8; Fri, 29 Aug 2025 15:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756482508; bh=bjPVH71yYHRT38x+a2qhkcGYmz0Liwe3xJMHVBXj3C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4GMj8XNJnYSDWsfs1/7aLKXCLVOKZ7yv8HQwWtwyZnEetNUlm8SA50kW9PP6OEDx NGZzW0FTJk705rXkrEXLxamFE/2oOEUqpN9grsWkpCIGVwU8Hij/csR5bpcbN0bYwG yXeWLIwpIMRMmXTmy3XkRTX6y/oL4gmj76nkT/OANpVMGtS+p8vYXpRLWrrx2BB9km 4dTHsBupNUvqOzMwS80ThTT/Q7kjRw5OLPg2vyuc3e6FBhFBev3YVA85acO1APtp6E T1Q1Fd/n0RblJ8pM6UudIMidLJlEG7i3iWh7/rv7saey7ZAOMmpYaEuguTQglYGiKi S+8j6wmij56kQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Marco Crivellari , Michal Hocko , Peter Zijlstra , Tejun Heo , Thomas Gleixner , Waiman Long Subject: [PATCH 03/33] cpu: Revert "cpu/hotplug: Prevent self deadlock on CPU hot-unplug" Date: Fri, 29 Aug 2025 17:47:44 +0200 Message-ID: <20250829154814.47015-4-frederic@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829154814.47015-1-frederic@kernel.org> References: <20250829154814.47015-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 1) The commit: 2b8272ff4a70 ("cpu/hotplug: Prevent self deadlock on CPU hot-unplug") was added to fix an issue where the hotplug control task (BP) was throttled between CPUHP_AP_IDLE_DEAD and CPUHP_HRTIMERS_PREPARE waiting in the hrtimer blindspot for the bandwidth callback queued in the dead CPU. 2) Later on, the commit: 38685e2a0476 ("cpu/hotplug: Don't offline the last non-isolated CPU") plugged on the target selection for the workqueue offloaded CPU down process to prevent from destroying the last CPU domain. 3) Finally: 5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earl= ier") removed entirely the conditions for the race exposed and partially fixed in 1). The offloading of the CPU down process to a workqueue on another CPU then becomes unnecessary. But the last CPU belonging to scheduler domains must still remain online. Therefore revert the now obsolete commit 2b8272ff4a70b866106ae13c36be7ecbef5d5da2 and move the housekeeping check under the cpu_hotplug_lock write held. Since HK_TYPE_DOMAIN will include both isolcpus and cpuset isolated partition, the hotplug lock will synchronize against concurrent cpuset partition updates. Signed-off-by: Frederic Weisbecker --- kernel/cpu.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index db9f6c539b28..453a806af2ee 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1410,6 +1410,16 @@ static int __ref _cpu_down(unsigned int cpu, int tas= ks_frozen, =20 cpus_write_lock(); =20 + /* + * 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)) >=3D nr_cpu_ids) { + ret =3D -EBUSY; + goto out; + } + cpuhp_tasks_frozen =3D tasks_frozen; =20 prev_state =3D cpuhp_set_state(cpu, st, target); @@ -1456,22 +1466,8 @@ static int __ref _cpu_down(unsigned int cpu, int tas= ks_frozen, return ret; } =20 -struct cpu_down_work { - unsigned int cpu; - enum cpuhp_state target; -}; - -static long __cpu_down_maps_locked(void *arg) -{ - struct cpu_down_work *work =3D arg; - - return _cpu_down(work->cpu, 0, work->target); -} - static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target) { - struct cpu_down_work work =3D { .cpu =3D cpu, .target =3D target, }; - /* * If the platform does not support hotplug, report it explicitly to * differentiate it from a transient offlining failure. @@ -1480,18 +1476,7 @@ static int cpu_down_maps_locked(unsigned int cpu, en= um cpuhp_state target) return -EOPNOTSUPP; if (cpu_hotplug_disabled) return -EBUSY; - - /* - * Ensure that the control task does not run on the to be offlined - * CPU to prevent a deadlock against cfs_b->period_timer. - * Also keep at least one housekeeping cpu onlined to avoid generating - * an empty sched_domain span. - */ - for_each_cpu_and(cpu, cpu_online_mask, housekeeping_cpumask(HK_TYPE_DOMAI= N)) { - if (cpu !=3D work.cpu) - return work_on_cpu(cpu, __cpu_down_maps_locked, &work); - } - return -EBUSY; + return _cpu_down(cpu, 0, target); } =20 static int cpu_down(unsigned int cpu, enum cpuhp_state target) --=20 2.51.0