From patchwork Tue Oct 24 13:20:58 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: 157460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1938184vqx; Tue, 24 Oct 2023 06:23:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU4y3XupOF2j/79PshUfBpH1WRNYFp6YZ2FDx7L36MvixrkXKt1K7pvKJinSkUtQ7Pp08w X-Received: by 2002:a17:90a:a38d:b0:27d:3fa4:9d9a with SMTP id x13-20020a17090aa38d00b0027d3fa49d9amr9471038pjp.29.1698153795715; Tue, 24 Oct 2023 06:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153795; cv=none; d=google.com; s=arc-20160816; b=Ybj1lEQIiVEZ07K2TD3gkerYxOdJKIjJy7hxehWi/5uz7JwNdoc4kndY4oq3IzHdLD HxRi9qIeatMaKhOf0Yoqtvx6eP11aywr0kEJRRnFFflnI6MIaIrE9Sgk21abxLlMaJ6P q3ItNNvU/jcYuujF1AF7QeyaKURLZbSAY8UZewJLlpzvrqW4zKpSzcW1z8NNYYIC+2xV P/BbtAmqX8R68mK+y77YuVFJu7hvdcxnc8UNbZaHeTFQnDriCLslj8NxVFajfbqIMX7P 4VD6NOSSnAflvBPwivi93uQfyfLQYSNgFckH/w1uMbaIMGedE8wNJrtMBzwlgqKJ2U/W nANw== 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=V4ecj8dTDYA1IyyMtmPGKsFad/wZPBOHhKIZjfIhAss=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=GsSUouCtRikbHjqh52a9Zjozv5ZrlcdpL7Ad7Nfbfi6kH+DZRr7X22yeQ9lxjYER6O M8zXpClayGrzwR3zu0+2lVB6mHFrKQ8g2m753AOP2DA7JtT1lerFRO3ouxEkVCbV+5aQ dMybZ1LEultezHJDIjb0gVIoUSAqLfvEZ7YJ2pB9g6CLhoXlpOwGDKWTBdP5feOdplDf TsjcHcupjkybt7QYRmDwlOgL2H9rD6lR9nXBPb3pvyUyuKLJkkPr1DxcSKcpCvljrcFF v2WnUmZpSOzKEwAqXy0RwPZ7h1Y5RHPdAYLSCwBONIGo+ZIbPZ7rXPw3vXbxOlCbncRZ 87Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kqMZnmQA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d11-20020a17090ab30b00b002791cef6654si10947790pjr.1.2023.10.24.06.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:23:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kqMZnmQA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 990FF80B815B; Tue, 24 Oct 2023 06:23:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234742AbjJXNWK (ORCPT + 26 others); Tue, 24 Oct 2023 09:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234654AbjJXNVe (ORCPT ); Tue, 24 Oct 2023 09:21:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60DCF171B; Tue, 24 Oct 2023 06:21:01 -0700 (PDT) Date: Tue, 24 Oct 2023 13:20:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698153659; 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=V4ecj8dTDYA1IyyMtmPGKsFad/wZPBOHhKIZjfIhAss=; b=kqMZnmQAKka1MOgTfUpoTbsLu7GyCjaTUAf/DTlm033XKs+1ueJgXeIbmr+NGJRVNXtRti YjlUtePpX3uTuNzwYS/UysaodCs0n7Wv/WOpkhUOpLezyvD4xoL2dkeCrUeQU7InYVhNxJ LyTzUjXrwVRANmGHAmEyOG/VIZiJMU3y1DKxHSJsANVLSUPo4KXD53sMXGWF/Q/BYh4G+A W1t1+4156YkmT0//sVkLEJJScFn9OctNQ9c/z6DA+qaaoTu4K0kCdxxV5l85nw6GT4puhj SXar7c/AEAN/dMNU040I2SOPl2iVIgD/jAgGIj4f+6CWj0XhHtBGqIbBBMygNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698153659; 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=V4ecj8dTDYA1IyyMtmPGKsFad/wZPBOHhKIZjfIhAss=; b=CS5UoPjnWSxDzWNc4Ki91CtZ5kjnUeK7lRVUGYdfXf06+a7tKSFTOGZmCdz1hc4sNFXKWB Kno7Qx2gEHxHByAg== 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: x86/microcode] x86/microcode: Get rid of the schedule work indirection Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231017211723.354748138@linutronix.de> References: <20231017211723.354748138@linutronix.de> MIME-Version: 1.0 Message-ID: <169815365881.3135.12389169576692651192.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:23:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780039523467661165 X-GMAIL-MSGID: 1780643314493746388 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 2e1997335ceb6fc819862804f51d4fe83593c138 Gitweb: https://git.kernel.org/tip/2e1997335ceb6fc819862804f51d4fe83593c138 Author: Thomas Gleixner AuthorDate: Tue, 17 Oct 2023 23:23:58 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 24 Oct 2023 15:05:54 +02:00 x86/microcode: Get rid of the schedule work indirection Scheduling work on all CPUs to collect the microcode information is just another extra step for no value. Let the CPU hotplug callback registration do it. Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231017211723.354748138@linutronix.de --- arch/x86/kernel/cpu/microcode/core.c | 29 +++++++++------------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 37145cf..0ed96d2 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -481,8 +481,16 @@ static struct syscore_ops mc_syscore_ops = { static int mc_cpu_online(unsigned int cpu) { + struct ucode_cpu_info *uci = ucode_cpu_info + cpu; struct device *dev = get_cpu_device(cpu); + memset(uci, 0, sizeof(*uci)); + + microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); + cpu_data(cpu).microcode = uci->cpu_sig.rev; + if (!cpu) + boot_cpu_data.microcode = uci->cpu_sig.rev; + if (sysfs_create_group(&dev->kobj, &mc_attr_group)) pr_err("Failed to create group for CPU%d\n", cpu); return 0; @@ -503,20 +511,6 @@ static int mc_cpu_down_prep(unsigned int cpu) return 0; } -static void setup_online_cpu(struct work_struct *work) -{ - int cpu = smp_processor_id(); - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - - memset(uci, 0, sizeof(*uci)); - - microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); - cpu_data(cpu).microcode = uci->cpu_sig.rev; - if (!cpu) - boot_cpu_data.microcode = uci->cpu_sig.rev; - mc_cpu_online(cpu); -} - static struct attribute *cpu_root_microcode_attrs[] = { #ifdef CONFIG_MICROCODE_LATE_LOADING &dev_attr_reload.attr, @@ -562,12 +556,9 @@ static int __init microcode_init(void) } } - /* Do per-CPU setup */ - schedule_on_each_cpu(setup_online_cpu); - register_syscore_ops(&mc_syscore_ops); - cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online", - mc_cpu_online, mc_cpu_down_prep); + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/microcode:online", + mc_cpu_online, mc_cpu_down_prep); pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);