From nobody Sun Feb 8 12:20:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D9E5C77B75 for ; Tue, 16 May 2023 09:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjEPJLR (ORCPT ); Tue, 16 May 2023 05:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231817AbjEPJKH (ORCPT ); Tue, 16 May 2023 05:10:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C98C935AC; Tue, 16 May 2023 02:10:04 -0700 (PDT) Date: Tue, 16 May 2023 09:09:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684228200; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iumz4nYEL/eZH8YC/m5GHga++Vy/iQFId5+7wJh361g=; b=IWRjGTSg9wd7zx8Ge/KuatrCVMV95GML14viMSKJFJs4cI5hbnTHk+1/CgMzcxlWOewH0z fdfoh7J3jQaI6s4xSGL1ONfulIEsNT7fhEkc3xpRPmhTeBMM8/pHnH7kWt5RH0kKIH9brr PCU9W5uW1r8up3ARAD3upCZ2RMSc0wbtrPCcsKPQWXO4o808Gqy3pl8Do4COT/UmdwyHIE fKj4pEyscU5GDwmWl7XTJFrwbE/2M0RPTAnMdsMIlLTJQi3mXBZ4gUoc8Z7zftLtHSQvr9 yulVQ413IbPdR8zf98II8eyn+XSndE8B7juvkX516DAjyUoOl6KXFqDI0S526A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684228200; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iumz4nYEL/eZH8YC/m5GHga++Vy/iQFId5+7wJh361g=; b=q9QvoAPghBUA0YnEc8ZWGmd8umozTdmVGbDcOXXRgc2xap17mNT1Y2wklUOi0VqOZUiw11 j5yt6zDI1YLimVAw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Rework sparse_irq locking in bringup_cpu() Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , Michael Kelley , Oleksandr Natalenko , Helge Deller , "Guilherme G. Piccoli" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230512205256.263722880@linutronix.de> References: <20230512205256.263722880@linutronix.de> MIME-Version: 1.0 Message-ID: <168422819974.404.13412319672677019398.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: 22b612e2d53f6e13ce7b55ed565a104512f0eb00 Gitweb: https://git.kernel.org/tip/22b612e2d53f6e13ce7b55ed565a10451= 2f0eb00 Author: Thomas Gleixner AuthorDate: Fri, 12 May 2023 23:07:21 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 15 May 2023 13:44:54 +02:00 cpu/hotplug: Rework sparse_irq locking in bringup_cpu() There is no harm to hold sparse_irq lock until the upcoming CPU completes in cpuhp_online_idle(). This allows to remove cpu_online() synchronization from architecture code. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Tested-by: Michael Kelley Tested-by: Oleksandr Natalenko Tested-by: Helge Deller # parisc Tested-by: Guilherme G. Piccoli # Steam Deck Link: https://lore.kernel.org/r/20230512205256.263722880@linutronix.de --- kernel/cpu.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index c0d859c..df8f137 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -558,7 +558,7 @@ static int cpuhp_kick_ap(int cpu, struct cpuhp_cpu_stat= e *st, return ret; } =20 -static int bringup_wait_for_ap(unsigned int cpu) +static int bringup_wait_for_ap_online(unsigned int cpu) { struct cpuhp_cpu_state *st =3D per_cpu_ptr(&cpuhp_state, cpu); =20 @@ -579,15 +579,12 @@ static int bringup_wait_for_ap(unsigned int cpu) */ if (!cpu_smt_allowed(cpu)) return -ECANCELED; - - if (st->target <=3D CPUHP_AP_ONLINE_IDLE) - return 0; - - return cpuhp_kick_ap(cpu, st, st->target); + return 0; } =20 static int bringup_cpu(unsigned int cpu) { + struct cpuhp_cpu_state *st =3D per_cpu_ptr(&cpuhp_state, cpu); struct task_struct *idle =3D idle_thread_get(cpu); int ret; =20 @@ -600,16 +597,33 @@ static int bringup_cpu(unsigned int cpu) /* * Some architectures have to walk the irq descriptors to * setup the vector space for the cpu which comes online. - * Prevent irq alloc/free across the bringup. + * + * Prevent irq alloc/free across the bringup by acquiring the + * sparse irq lock. Hold it until the upcoming CPU completes the + * startup in cpuhp_online_idle() which allows to avoid + * intermediate synchronization points in the architecture code. */ irq_lock_sparse(); =20 /* Arch-specific enabling code. */ ret =3D __cpu_up(cpu, idle); - irq_unlock_sparse(); if (ret) - return ret; - return bringup_wait_for_ap(cpu); + goto out_unlock; + + ret =3D bringup_wait_for_ap_online(cpu); + if (ret) + goto out_unlock; + + irq_unlock_sparse(); + + if (st->target <=3D CPUHP_AP_ONLINE_IDLE) + return 0; + + return cpuhp_kick_ap(cpu, st, st->target); + +out_unlock: + irq_unlock_sparse(); + return ret; } =20 static int finish_cpu(unsigned int cpu)