From patchwork Mon Oct 9 12:29:49 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: 150045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1833375vqo; Mon, 9 Oct 2023 05:31:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWf3p0Dh+E5htoQ+/hlLkcnVIxaGZesNNicagVlmq6zbvG9neVRz8hAEmOOdCjiDENZa5Q X-Received: by 2002:a05:6358:7e49:b0:145:707f:ebe1 with SMTP id p9-20020a0563587e4900b00145707febe1mr16439456rwm.12.1696854708016; Mon, 09 Oct 2023 05:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854707; cv=none; d=google.com; s=arc-20160816; b=wsFg6pyIN0gt3lqk5nTEj2NZ2kBKc9f0bnwct6SO9t85eZXVdFVqFqPeTmPgYUvzza cFWU9amoOCnE81zuOMq0tHXvmgW2EEc5SaJ35Dv6iUYltjZVRXALOuI+MeES81Im/xnW 1d/xrmoC64eOaYHcrrQvu9x/s2ZUDS3czvYOuhX5N23ZJpvZJf7c/9Ba+0F4COvFCDGh EaJc2zWR/R7l4RQQoV48han0XwmwNCf6ofJD+hF1BQd9ksMVN8QUFlk5DKz0e1O44B0P kSvsh5EYSpTmIM6ZE5QzueMsR3Ekr4vLheEryjZS6ZPzTBsElLmdeOXjeSEFmz0RQsxp XxvQ== 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=d4DCucT7/EZFCI+kh4lJsqBUmDcTN+vyqxUnjFD4UII=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=cewffGLjRoBmsS4/cjUlOT7HMIFy7oZpPgRTTyQLwsqetSZ4yB9mZS7NLRiOLAqblQ DUbPb7RaOJlcnck4Mz1SKx1X1uPG2DK7MPUAzZ/1PtM60q6Guxe9NSY+9/nQb6DajcxQ dLAJcpzKr8D7h+oxpPe0yj1tIfdbUJJC6wbmFga1wbDYeBJ75BEd6PVb0F1iRzo5YlT3 dBb8Qv31LOmSJUPnOVZzuzC6Y936Z5tGaXwEg0KhaP8uJPFhZKHHnZuoKFqtLGroHL1B UNbHXmn35JIMhDLRNTjPmjuC2c4wYXpHngURtSbggGoSTUkLPLWGqq7pdK1ZdBCQf6JU s56A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JavF7j9x; 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 mm16-20020a17090b359000b0025bb4a1c12esi9322377pjb.148.2023.10.09.05.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:31:47 -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=JavF7j9x; 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 7B6A18090E80; Mon, 9 Oct 2023 05:30:46 -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 S1376585AbjJIMa3 (ORCPT + 18 others); Mon, 9 Oct 2023 08:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346564AbjJIM3z (ORCPT ); Mon, 9 Oct 2023 08:29:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D5BDF; Mon, 9 Oct 2023 05:29:52 -0700 (PDT) Date: Mon, 09 Oct 2023 12:29:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696854590; 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=d4DCucT7/EZFCI+kh4lJsqBUmDcTN+vyqxUnjFD4UII=; b=JavF7j9xutBTHRG68IG3yFubc/40y+bYiuZdo1mYB4uTplcBboSENOocCaAbjDM2Ou9Yfz WvyGTuHDiHCSs8bHrzJ6vRB59WOJe+Z53NnFapNk2xlq9oJFgGkK72tgOWtUZQ9AbSdIrK UYPZS9MjwWo/aojy39ev2qEqzVTtGNHAlmaJKVf9TvH7l8JHM592/U8DauO6EasovVR31F OOh12S9FpbE7CfRC5rRSmxHOEil6suy95+Zu3z7a4xyUc6T/JOm0fZxSXixt1s+1opuiRj G91X1FtDJJ6YOPZdTiLbQCdl28FuSM2O0H27hkfbTeA7yeevuPqy6RsFTddftA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696854590; 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=d4DCucT7/EZFCI+kh4lJsqBUmDcTN+vyqxUnjFD4UII=; b=U+zGahwU5kwPSoCEZDbQ+jeUi27BmdDXMx102VEMiot+U8bO0ivCI+PW4HPw42R8EldI/4 XRTnUZ6Npx1jlPDg== 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: <20231002115902.971709581@linutronix.de> References: <20231002115902.971709581@linutronix.de> MIME-Version: 1.0 Message-ID: <169685458989.3135.1074830869300543674.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Mon, 09 Oct 2023 05:30:46 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778685894461026861 X-GMAIL-MSGID: 1779281122273819005 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: f4a21dcbdbfaaa6841d528e5124c581e90c945fe Gitweb: https://git.kernel.org/tip/f4a21dcbdbfaaa6841d528e5124c581e90c945fe Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 13:59:54 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 06 Oct 2023 15:12:19 +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/20231002115902.971709581@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 6f7632f..17b7578 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -519,8 +519,16 @@ static int mc_cpu_starting(unsigned int cpu) 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; @@ -541,20 +549,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, @@ -600,14 +594,11 @@ 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_MICROCODE_LOADER, "x86/microcode:starting", mc_cpu_starting, NULL); - 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);