From patchwork Wed Feb 1 20:43:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 4835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp502313wrn; Wed, 1 Feb 2023 12:46:07 -0800 (PST) X-Google-Smtp-Source: AK7set81YzVnYDF7FKDWkZUlFtQtAjJOqfXA02ikUgzj6yuN3A/VtqnphZhEo/Mlo8iPdbvLOzbn X-Received: by 2002:a17:902:eccb:b0:195:e834:31de with SMTP id a11-20020a170902eccb00b00195e83431demr4315046plh.27.1675284367374; Wed, 01 Feb 2023 12:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675284367; cv=none; d=google.com; s=arc-20160816; b=sNx5nuA93qL1ng1rpSly+2Pe7fOHNmF0K7uD+PgUN1xOkjcdmmde2d+8Bp6Npp4nHi iIFwPPTJs9lN9H10AT8XG6vAUMh1gH5rp+mjhhKiChnysFgz4cRCUqTgKp7b2CkS5jlB gzE9GBJj3QtCe6j+7h0OT1lpmT07gBfJ62IoiZFX5WOTO2MSzX3NwOCPHGf7vN7HjnfY clKqiHYDIatHJSAXHqtE9GAVjuZznl4aV/xGxZuiK/6KBCl7QYW/xFluMmAup1F/x1Y9 u62vmJLJSKFoOgtVFDlEgQjRwvobUywOWyc/jc/0EIAw+OMHUXI0mEmGiSO56USI+nxF mZqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MBkUStfA+iDGjKKAM+4p8+0mIlG33iS9Y15joN7auaU=; b=w5I3ciG94IIsBAkSoZmvrV+9wBmhOCsQPcbY2W9t7/GfwVye/X/Wpdlj7KjZdWlLfC WAIRI0CoFeVZ6dIjwnl4MVKPXfmVrfKJjMQp0Buh1fJJb0LQnvJpfrmaA7Vgzwe2BixE fjPGK75YEMFwNY/kcoy3lv6Y5sBWQkHeiuAcY9sBGCLZL9/wfy6nVwyD0D3heZbttXn7 IkZCIR3t2HVYtNab3Whg+xnt1Gb54oFu7psnan1gZ8jut4NMnCr/aSCtT2E0B4QzY3Y6 yEz2n5xQmNHdkxlkydjgolL36iIJBASjnXCumB8XL7DnE88hEz2RYQVJizqMJTk3eKHm XpvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=p8tndsXy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a170902e29100b001947ba0ac92si18331685plc.350.2023.02.01.12.45.31; Wed, 01 Feb 2023 12:46:07 -0800 (PST) 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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=p8tndsXy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229974AbjBAUpP (ORCPT + 99 others); Wed, 1 Feb 2023 15:45:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbjBAUpL (ORCPT ); Wed, 1 Feb 2023 15:45:11 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7395B78AE3 for ; Wed, 1 Feb 2023 12:44:48 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso2293238wms.5 for ; Wed, 01 Feb 2023 12:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MBkUStfA+iDGjKKAM+4p8+0mIlG33iS9Y15joN7auaU=; b=p8tndsXy9zB48jq6U4H/0wBOP0dK7C9M6YI8SpeKZhYJkxaHanw6+Ix1tUU231B/5k QSuqVj3WcIbAArBi3dVGZOsJDyxJwzhPUUnIIjBaEJ8rMjetZrs8qfNnBx7OHdB6r3SI FC8ehdA/NTaFV4Jm/4yQb6tH65UEYu5nNm26PTL0b+TL0RT3h1fE0yH6V3XqRXrC9myu +m7w9k8yH36blhlSClNqJZq1G3TG2auYToYac5s3EuQfM5OhNVoc2bjZVshe9VwvoRuX WUvJq8W8Uw84kVvU0dwsJa3q23Zy8nNz5nXE7Go6KIbBHTg7DGYgUKvu0kOqXgS7uIos ziYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MBkUStfA+iDGjKKAM+4p8+0mIlG33iS9Y15joN7auaU=; b=Y6s/87QtLPdIPw9zEw7dZ+DxigiWIhsrHFI55M8iZfzj1MFue47YOa7FA6MiC0QFBI pNftQCSWtFIt0hxoZp92RN5IS7nmAgabwaYuTxjbXNsRCKhKM9PYuKDvIK9GlYHxjQmT n7iLS7x6rxNpXS7k0CqVbDWF7dtgN1dUhvos1b2DASpR9wRSf6tb60As/E523xngUSgK E1j6E3QKDDqvhwpgZrCI/3r37aKyk4YDbkzl3Ix1SI875xaBvRt8axxktH7dXWy2kvFk En3pN0wKfFhUzD6XezKKN23zU8LX6AD4lGpvZ6jSeH4YnyMIRg/ZLJGyESbLNxvqsIkU 4h8A== X-Gm-Message-State: AO0yUKWClFiL4RXOjcZ2Ahw7TRKs2Ki76D2Ks7cgklAVpiVGSPC7Zhqv XB29M9SzLWX4V+UwyScgJazuQA== X-Received: by 2002:a05:600c:16c4:b0:3dc:16d2:ae5e with SMTP id l4-20020a05600c16c400b003dc16d2ae5emr3423164wmn.32.1675284286944; Wed, 01 Feb 2023 12:44:46 -0800 (PST) Received: from usaari01.cust.communityfibre.co.uk ([2a02:6b6a:b566:0:7611:c340:3d8d:d46c]) by smtp.gmail.com with ESMTPSA id n15-20020a5d598f000000b002bdff778d87sm19993584wri.34.2023.02.01.12.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 12:44:46 -0800 (PST) From: Usama Arif To: dwmw2@infradead.org, tglx@linutronix.de Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, paulmck@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, rcu@vger.kernel.org, mimoja@mimoja.de, hewenliang4@huawei.com, thomas.lendacky@amd.com, seanjc@google.com, pmenzel@molgen.mpg.de, fam.zheng@bytedance.com, punit.agrawal@bytedance.com, simon.evans@bytedance.com, liangma@liangbit.com, Usama Arif Subject: [PATCH 0/9] Parallel CPU bringup for x86_64 Date: Wed, 1 Feb 2023 20:43:29 +0000 Message-Id: <20230201204338.1337562-1-usama.arif@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1756662980780685863?= X-GMAIL-MSGID: =?utf-8?q?1756662980780685863?= This patchseries is from the work done by David Woodhouse (v4: https://lore.kernel.org/all/20220201205328.123066-1-dwmw2@infradead.org/). The parallel CPU bringup is disabled for all AMD CPUs in this version: (see discussions: https://lore.kernel.org/all/bc3f2b1332c4bb77558df8aa36493a55542fe5b9.camel@infradead.org/ and https://lore.kernel.org/all/3b6ac86fdc800cac5806433daf14a9095be101e9.camel@infradead.org/). Doing INIT/SIPI/SIPI in parallel brings down the time for smpboot from ~700ms to 100ms (85% improvement) on a server with 128 CPUs split across 2 NUMA nodes. Adding another cpuhp state for do_wait_cpu_initialized to make sure cpu_init is reached in parallel as proposed by David in v1 will bring it down further to ~30ms. Making this change would be dependent on this patchseries, so they could be explored if this gets merged. Changes across versions: v2: Cut it back to just INIT/SIPI/SIPI in parallel for now, nothing more v3: Clean up x2apic patch, add MTRR optimisation, lock topology update in preparation for more parallelisation. v4: Fixes to the real mode parallelisation patch spotted by SeanC, to avoid scribbling on initial_gs in common_cpu_up(), and to allow all 24 bits of the physical X2APIC ID to be used. That patch still needs a Signed-off-by from its original author, who once claimed not to remember writing it at all. But now we've fixed it, hopefully he'll admit it now :) v5: rebase to v6.1 and remeasure performance, disable parallel bringup for AMD CPUs. David Woodhouse (8): x86/apic/x2apic: Fix parallel handling of cluster_mask cpu/hotplug: Move idle_thread_get() to cpu/hotplug: Add dynamic parallel bringup states before CPUHP_BRINGUP_CPU x86/smpboot: Reference count on smpboot_setup_warm_reset_vector() x86/smpboot: Split up native_cpu_up into separate phases and document them x86/smpboot: Send INIT/SIPI/SIPI to secondary CPUs in parallel x86/mtrr: Avoid repeated save of MTRRs on boot-time CPU bringup x86/smpboot: Serialize topology updates for secondary bringup Thomas Gleixner (1): x86/smpboot: Support parallel startup of secondary CPUs arch/x86/include/asm/realmode.h | 3 + arch/x86/include/asm/smp.h | 13 +- arch/x86/include/asm/topology.h | 2 - arch/x86/kernel/acpi/sleep.c | 1 + arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 108 +++++---- arch/x86/kernel/cpu/common.c | 6 +- arch/x86/kernel/cpu/mtrr/mtrr.c | 9 + arch/x86/kernel/head_64.S | 73 ++++++ arch/x86/kernel/smpboot.c | 324 ++++++++++++++++++-------- arch/x86/realmode/init.c | 3 + arch/x86/realmode/rm/trampoline_64.S | 14 ++ arch/x86/xen/smp_pv.c | 4 +- include/linux/cpuhotplug.h | 2 + include/linux/smpboot.h | 7 + kernel/cpu.c | 27 ++- kernel/smpboot.c | 2 +- kernel/smpboot.h | 2 - 18 files changed, 443 insertions(+), 159 deletions(-)