From patchwork Tue May 16 09:09:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 94577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp287243vqo; Tue, 16 May 2023 02:19:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ402JhNRbemHVCTIOUM/2mNRxhGPIcTiaw7DI9izdaFjGyxmbSMZn9oywiEP/+D2RwWYt92 X-Received: by 2002:a17:902:c943:b0:1a9:2a9e:30a8 with SMTP id i3-20020a170902c94300b001a92a9e30a8mr53619042pla.9.1684228772691; Tue, 16 May 2023 02:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684228772; cv=none; d=google.com; s=arc-20160816; b=mMPd09Seu2KGd0jo/fnHd1VW4YNVcBXhaNNC361Pl93hKGVumbStxIuCIgc+UFzNX6 wB8zekVJ6ugLB1JmLvyrGaP0s74iUTHSUoxOLEnUSo+0aKqR7dd+mrPYR9SrOyX7Oye6 F5CF65ma0ARXSjEXsDBpEojltRiWfQzSlkgIROV4djxHpCS/GlvCAIk7fJ9loXyjDBG+ f9WfC9DWuB4GDvGAEe6bRTFkRnEsZPz/cPGIRMc8z0oJoFIEU6nXyuzOvdIWWOkIuabx 74RZa3DEzI3NZgu2uHjjbxuJUk1w6TefRJbSe/j3WlADoaaQ1S9P9wosaAbjbHNSLbWJ M1Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=iumz4nYEL/eZH8YC/m5GHga++Vy/iQFId5+7wJh361g=; b=PnsM7tGGt+vZRQBJ4bR2pP0cA2qvBmltv4LJ2cviHH0dvR9+OUthWJVaK+zScIVV2j TLPxyxQzUg6jbXJQPPYySXOy8Nuvu856H45CdGTszyWFzLzzxHMs+SRigbY9kDIW+19A mJPuGG9niQNxDeWPLPnArGyhJIH26ccFU/I7KxCnUNS4C19y4mjT7iulSHjjORbcDVqp oahRvmvmYtavvRdvw2loDSuV6k3viWN/L8NH6MPho4faeBsn6vHt2hcLUbTSmFvdlOXR WyT0LN/jo3XFWoMvtWuiMF2fY14jQcgu3pWpwZkNjEJQ3oEEIiqWSHax2DG13UoLQG0C Fdgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IWRjGTSg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=q9QvoAPg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001a1cefdaa33si18957271plk.342.2023.05.16.02.19.21; Tue, 16 May 2023 02:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IWRjGTSg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=q9QvoAPg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjEPJLQ (ORCPT + 99 others); Tue, 16 May 2023 05:11:16 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765724557878308919?= X-GMAIL-MSGID: =?utf-8?q?1766041869470017392?= The following commit has been merged into the smp/core branch of tip: Commit-ID: 22b612e2d53f6e13ce7b55ed565a104512f0eb00 Gitweb: https://git.kernel.org/tip/22b612e2d53f6e13ce7b55ed565a104512f0eb00 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_state *st, return ret; } -static int bringup_wait_for_ap(unsigned int cpu) +static int bringup_wait_for_ap_online(unsigned int cpu) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); @@ -579,15 +579,12 @@ static int bringup_wait_for_ap(unsigned int cpu) */ if (!cpu_smt_allowed(cpu)) return -ECANCELED; - - if (st->target <= CPUHP_AP_ONLINE_IDLE) - return 0; - - return cpuhp_kick_ap(cpu, st, st->target); + return 0; } static int bringup_cpu(unsigned int cpu) { + struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); struct task_struct *idle = idle_thread_get(cpu); int ret; @@ -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(); /* Arch-specific enabling code. */ ret = __cpu_up(cpu, idle); - irq_unlock_sparse(); if (ret) - return ret; - return bringup_wait_for_ap(cpu); + goto out_unlock; + + ret = bringup_wait_for_ap_online(cpu); + if (ret) + goto out_unlock; + + irq_unlock_sparse(); + + if (st->target <= CPUHP_AP_ONLINE_IDLE) + return 0; + + return cpuhp_kick_ap(cpu, st, st->target); + +out_unlock: + irq_unlock_sparse(); + return ret; } static int finish_cpu(unsigned int cpu)