From patchwork Fri May 12 21:07:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 93377 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp5393366vqo; Fri, 12 May 2023 14:12:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TsC2J0srod3AvDSgIH/DU7pkybe/F0pTo172OXFZNsnTny7lQkH0Z72ZwQOqp+IK2WXCu X-Received: by 2002:a17:903:10a:b0:1ab:11c8:777a with SMTP id y10-20020a170903010a00b001ab11c8777amr24939343plc.13.1683925969221; Fri, 12 May 2023 14:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683925969; cv=none; d=google.com; s=arc-20160816; b=NWaQNGxVMrxO+OV57bThdhjqUTgmqX3oL4IJ1S9rzVX70AtirRt+a5e0oLhnmuXb0+ dEF6bVtE3jMoYWBqkoUHzsBcr216aBGwxWAwAGIl/3THAfX6cSlnOmB7xlE2jjlAnO11 MwN3GUrLp5c7m4lws0qhD8OqTJ7xI2xFNzgIXI9s+LMQigsF/hdQYbYhvhvVAjmOEJf8 uqa8A4FR8Nv7VdDAiWn9uGfsi5PSZWOHcr+f5oUcDqs9FrafSKZEOVaNEWmcjadgNEZ6 8zPUxCgxLc1FGrgPHdZ8wVWA8LlMm61pZLhPNsnWdNRupxNlFBFkNwEsmtRDTJxBaq0O 9Paw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=s6m9J4c1JvP70cnTGmFjRaHjxV+T4Hc55BQMBWx1oPc=; b=zOoYCZUYWDp/1fpX3iu0M6NFwSaNBdlXslXCRufDZYRp+smYdlLPER390vBRV0BVQq a2TaYMMdKMdm49qErPu7PKM/jZi1O86sA/4Iw5RkbE4SUS4T3iJovGVHeMPImcWT7vsm thtPIXkguq6ooditmZtskzVIPS5Jo/+WnUv90esIfa62YujWFN6MmazwvhQUzQZMzlc0 /jtV11G6Rn3qRU8GFYUhSJNJQAKHNzndIL6nFg0jVNHT5iy/U+O+BPufBl6PHIc6Me8X sbvrgEkxtkcI5UiBGz+9+6U7ZtIvU5W5POrjWX7sRBXYsmnqk/plyyTibgHggVvlki96 DoKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=y2DUc1fX; dkim=neutral (no key) header.i=@linutronix.de header.b=yCQezV+n; 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 c9-20020a170902d48900b001a9f42553ddsi10821600plg.296.2023.05.12.14.12.30; Fri, 12 May 2023 14:12:49 -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=y2DUc1fX; dkim=neutral (no key) header.i=@linutronix.de header.b=yCQezV+n; 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 S240009AbjELVJy (ORCPT + 99 others); Fri, 12 May 2023 17:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239869AbjELVJR (ORCPT ); Fri, 12 May 2023 17:09:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57221106D6; Fri, 12 May 2023 14:08:00 -0700 (PDT) Message-ID: <20230512205257.133453992@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683925667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s6m9J4c1JvP70cnTGmFjRaHjxV+T4Hc55BQMBWx1oPc=; b=y2DUc1fXfsXkDW8K6WaMiHDe6gR4IEKxgaOddkKmSwSv+DqEsvnjWzXgPjyq32d1wpWK5Z DhULLjmoSJ6Twf97uZUUSDmOErh5HW4b2tsf6z1y+M36Y3f2xB7zi4wFgw7y4DDIduarbz yeLsAcWQsBCl07tIF0QqY/Jj/avRssPe2AvWtNVRytlleptjLfnchKkKtZCHOE5wyaDkBF 6X8iVUK0NIWo0to7bK0cANrtWwlUAJ9ihLJH1D1NrqOK2ldq23z0J7UlmUsOUeID7o25Cf 4F7tlHyUzLkqHXoKB/QYb/4diEkgPLMMdkcjx5AD44P4tw9zfHRvswMyp4a7FQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683925667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s6m9J4c1JvP70cnTGmFjRaHjxV+T4Hc55BQMBWx1oPc=; b=yCQezV+nLz69U6F8kXkQMvva3l/BtuBu7i4swHXcyBl7X7TgPYqW8jXLbGqot3jpiZi7IT CU7Sn35pJ28UiwBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, David Woodhouse , Andrew Cooper , Brian Gerst , Arjan van de Veen , Paolo Bonzini , Paul McKenney , Tom Lendacky , Sean Christopherson , Oleksandr Natalenko , Paul Menzel , "Guilherme G. Piccoli" , Piotr Gorski , Usama Arif , Juergen Gross , Boris Ostrovsky , xen-devel@lists.xenproject.org, Russell King , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Guo Ren , linux-csky@vger.kernel.org, Thomas Bogendoerfer , linux-mips@vger.kernel.org, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , linux-riscv@lists.infradead.org, Mark Rutland , Sabin Rapan , "Michael Kelley (LINUX)" , Ross Philipson Subject: [patch V4 31/37] x86/smpboot: Enable split CPU startup References: <20230512203426.452963764@linutronix.de> MIME-Version: 1.0 Date: Fri, 12 May 2023 23:07:46 +0200 (CEST) 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?1765724357143615151?= X-GMAIL-MSGID: =?utf-8?q?1765724357143615151?= From: Thomas Gleixner The x86 CPU bringup state currently does AP wake-up, wait for AP to respond and then release it for full bringup. It is safe to be split into a wake-up and and a separate wait+release state. Provide the required functions and enable the split CPU bringup, which prepares for parallel bringup, where the bringup of the non-boot CPUs takes two iterations: One to prepare and wake all APs and the second to wait and release them. Depending on timing this can eliminate the wait time completely. Signed-off-by: Thomas Gleixner Tested-by: Michael Kelley --- arch/x86/Kconfig | 2 +- arch/x86/include/asm/smp.h | 9 ++------- arch/x86/kernel/smp.c | 2 +- arch/x86/kernel/smpboot.c | 8 ++++---- arch/x86/xen/smp_pv.c | 4 ++-- 5 files changed, 10 insertions(+), 15 deletions(-) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -274,8 +274,8 @@ config X86 select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_USER_RETURN_NOTIFIER select HAVE_GENERIC_VDSO - select HOTPLUG_CORE_SYNC_FULL if SMP select HOTPLUG_SMT if SMP + select HOTPLUG_SPLIT_STARTUP if SMP select IRQ_FORCED_THREADING select NEED_PER_CPU_EMBED_FIRST_CHUNK select NEED_PER_CPU_PAGE_FIRST_CHUNK --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -40,7 +40,7 @@ struct smp_ops { void (*cleanup_dead_cpu)(unsigned cpu); void (*poll_sync_state)(void); - int (*cpu_up)(unsigned cpu, struct task_struct *tidle); + int (*kick_ap_alive)(unsigned cpu, struct task_struct *tidle); int (*cpu_disable)(void); void (*cpu_die)(unsigned int cpu); void (*play_dead)(void); @@ -80,11 +80,6 @@ static inline void smp_cpus_done(unsigne smp_ops.smp_cpus_done(max_cpus); } -static inline int __cpu_up(unsigned int cpu, struct task_struct *tidle) -{ - return smp_ops.cpu_up(cpu, tidle); -} - static inline int __cpu_disable(void) { return smp_ops.cpu_disable(); @@ -124,7 +119,7 @@ void native_smp_prepare_cpus(unsigned in void calculate_max_logical_packages(void); void native_smp_cpus_done(unsigned int max_cpus); int common_cpu_up(unsigned int cpunum, struct task_struct *tidle); -int native_cpu_up(unsigned int cpunum, struct task_struct *tidle); +int native_kick_ap(unsigned int cpu, struct task_struct *tidle); int native_cpu_disable(void); void __noreturn hlt_play_dead(void); void native_play_dead(void); --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -268,7 +268,7 @@ struct smp_ops smp_ops = { #endif .smp_send_reschedule = native_smp_send_reschedule, - .cpu_up = native_cpu_up, + .kick_ap_alive = native_kick_ap, .cpu_disable = native_cpu_disable, .play_dead = native_play_dead, --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1052,7 +1052,7 @@ static int do_boot_cpu(int apicid, int c return ret; } -static int native_kick_ap(unsigned int cpu, struct task_struct *tidle) +int native_kick_ap(unsigned int cpu, struct task_struct *tidle) { int apicid = apic->cpu_present_to_apicid(cpu); int err; @@ -1088,15 +1088,15 @@ static int native_kick_ap(unsigned int c return err; } -int native_cpu_up(unsigned int cpu, struct task_struct *tidle) +int arch_cpuhp_kick_ap_alive(unsigned int cpu, struct task_struct *tidle) { - return native_kick_ap(cpu, tidle); + return smp_ops.kick_ap_alive(cpu, tidle); } void arch_cpuhp_cleanup_kick_cpu(unsigned int cpu) { /* Cleanup possible dangling ends... */ - if (smp_ops.cpu_up == native_cpu_up && x86_platform.legacy.warm_reset) + if (smp_ops.kick_ap_alive == native_kick_ap && x86_platform.legacy.warm_reset) smpboot_restore_warm_reset_vector(); } --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -314,7 +314,7 @@ cpu_initialize_context(unsigned int cpu, return 0; } -static int xen_pv_cpu_up(unsigned int cpu, struct task_struct *idle) +static int xen_pv_kick_ap(unsigned int cpu, struct task_struct *idle) { int rc; @@ -438,7 +438,7 @@ static const struct smp_ops xen_smp_ops .smp_prepare_cpus = xen_pv_smp_prepare_cpus, .smp_cpus_done = xen_smp_cpus_done, - .cpu_up = xen_pv_cpu_up, + .kick_ap_alive = xen_pv_kick_ap, .cpu_die = xen_pv_cpu_die, .cleanup_dead_cpu = xen_pv_cleanup_dead_cpu, .poll_sync_state = xen_pv_poll_sync_state,