From nobody Fri Dec 19 04:49:11 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5187CA0ECE for ; Tue, 12 Sep 2023 07:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbjILH7H (ORCPT ); Tue, 12 Sep 2023 03:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232157AbjILH6k (ORCPT ); Tue, 12 Sep 2023 03:58:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B32C51BEA for ; Tue, 12 Sep 2023 00:58:10 -0700 (PDT) Message-ID: <20230912065501.777893171@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694505489; 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=dBHUwt2VZzLKlhZD7lus6ZMnFKpXbbWJtwBvilrxafU=; b=WNmU6iY9mLJRMZGkGeQdBmj9PHK4NojOS348gK8kWx9n8wdhoIQtZv+pFsYG1i3+ow8lWJ i5Dmy30dLW1n/mUZasLMRQA8Pzl/HDnc14N+gw75DEqGyTaVK3ZQU/bhF9GNV9Lhl9JcYv s/TD/8kBRb3/AwVOcoKuBpDbrkIK4F6fHySkjTJiSx+314zh33lWZrGuS16Y7pONHPOvm5 RndoYo0gGdYKfoREkUS1gDSMkrXBzPfiogcW85PxfTvfyNbsYfac1qEFedxqXQY5qy8hQ1 CEESiNxNiQnnLFxKJrTdyrXu1uMvArjl+2i/6SbXsARUIJHGfoUeW3M5AtZ+9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694505489; 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=dBHUwt2VZzLKlhZD7lus6ZMnFKpXbbWJtwBvilrxafU=; b=fyo9/Q/8h/II6rdgCACFg1uN+807cKfPKMZbwfGmdh4g0z+kmveZDimC6jbu4fUdWuETXx WWkhie4MYJZXqRAg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov , "Chang S. Bae" , Arjan van de Ven , Nikolay Borisov Subject: [patch V3 16/30] x86/microcode: Get rid of the schedule work indirection References: <20230912065249.695681286@linutronix.de> MIME-Version: 1.0 Date: Tue, 12 Sep 2023 09:58:08 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- V2: New patch --- arch/x86/kernel/cpu/microcode/core.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -531,8 +531,16 @@ static struct syscore_ops mc_syscore_ops =20 static int mc_cpu_online(unsigned int cpu) { + struct ucode_cpu_info *uci =3D ucode_cpu_info + cpu; struct device *dev =3D get_cpu_device(cpu); =20 + memset(uci, 0, sizeof(*uci)); + + microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); + cpu_data(cpu).microcode =3D uci->cpu_sig.rev; + if (!cpu) + boot_cpu_data.microcode =3D 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; @@ -553,20 +561,6 @@ static int mc_cpu_down_prep(unsigned int return 0; } =20 -static void setup_online_cpu(struct work_struct *work) -{ - int cpu =3D smp_processor_id(); - struct ucode_cpu_info *uci =3D ucode_cpu_info + cpu; - - memset(uci, 0, sizeof(*uci)); - - microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); - cpu_data(cpu).microcode =3D uci->cpu_sig.rev; - if (!cpu) - boot_cpu_data.microcode =3D uci->cpu_sig.rev; - mc_cpu_online(cpu); -} - static struct attribute *cpu_root_microcode_attrs[] =3D { #ifdef CONFIG_MICROCODE_LATE_LOADING &dev_attr_reload.attr, @@ -612,12 +606,9 @@ static int __init microcode_init(void) } } =20 - /* 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); =20 pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);