mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sohil Mehta <sohil.mehta@intel.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	<linux-kernel@vger.kernel.org>, <x86@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Borislav Petkov <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] x86/microcode: Remove microcode_mutex.
Date: Thu, 3 Aug 2023 14:15:13 -0700	[thread overview]
Message-ID: <7f31f938-cd4f-bb1b-d44d-57adabf62c51@intel.com> (raw)
In-Reply-To: <20230803083253.VGMnC9Gd@linutronix.de>

Nit: The full stop at the end is not needed.

On 8/3/2023 1:32 AM, Sebastian Andrzej Siewior wrote:
> microcode_mutex is only used by reload_store().  It has a comment saying
> "to synchronize with each other". This probably means the sysfs
> interface vs the legacy interface which was removed in commit
> 181b6f40e9ea8 ("x86/microcode: Rip out the OLD_INTERFACE").
> 

There is also commit b6f86689d5b7 ("x86/microcode: Rip out the subsys
interface gunk") which last year removed another usage of microcode_mutex.

> The sysfs interface does not need additional synchronisation vs itself
> because it is provided as kernfs_ops::mutex which is acquired in
> kernfs_fop_write_iter().
> 
> Remove superfluous microcode_mutex.

I agree, the current usage does look unnecessary.

Maybe reword the commit message to say that after these two Rip outs
there are no of *other* usages of microcode_mutex to synchronize with?

> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> This poped up as "defined but not used" on RT builds without
> CONFIG_MICROCODE_LATE_LOADING enabled.

This issue has been raised a couple of times recently but the
justification has been deemed insufficient since it can't be reproduced
with a .config file.

See:
https://lore.kernel.org/lkml/20230324114720.1756466-1-john.ogness@linutronix.de/

and

https://lore.kernel.org/lkml/20230522062713.427998-1-christian.gmeiner@gmail.com/

However, your current justification of not needing the mutex itself
seems reasonable to me.

> 
>  arch/x86/kernel/cpu/microcode/core.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index 3afcf3de0dd49..2f9d35744bc41 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -54,15 +54,12 @@ LIST_HEAD(microcode_cache);
>   *
>   * All non cpu-hotplug-callback call sites use:
>   *
> - * - microcode_mutex to synchronize with each other;
>   * - cpus_read_lock/unlock() to synchronize with
>   *   the cpu-hotplug-callback call sites.
>   *
>   * We guarantee that only a single cpu is being
>   * updated at any particular moment of time.
>   */
> -static DEFINE_MUTEX(microcode_mutex);
> -
>  struct ucode_cpu_info		ucode_cpu_info[NR_CPUS];
>  
>  struct cpu_info_ctx {
> @@ -488,10 +485,7 @@ static ssize_t reload_store(struct device *dev,
>  	if (tmp_ret != UCODE_NEW)
>  		goto put;
>  
> -	mutex_lock(&microcode_mutex);
>  	ret = microcode_reload_late();
> -	mutex_unlock(&microcode_mutex);
> -
>  put:
>  	cpus_read_unlock();
>  

The code changes look fine to me.

You can also add below to the patch.

> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 52683fddafaf..777340724ec3 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -2276,8 +2276,7 @@ void store_cpu_caps(struct cpuinfo_x86 *curr_info)
>   * @prev_info: CPU capabilities stored before an update.
>   *
>   * The microcode loader calls this upon late microcode load to recheck features,
> - * only when microcode has been updated. Caller holds microcode_mutex and CPU
> - * hotplug lock.
> + * only when microcode has been updated. Caller holds CPU hotplug lock.
>   *
>   * Return: None
>   */






  reply	other threads:[~2023-08-03 21:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03  8:32 Sebastian Andrzej Siewior
2023-08-03 21:15 ` Sohil Mehta [this message]
2023-08-04  7:55   ` Sebastian Andrzej Siewior
2023-08-04  7:58     ` [PATCH v2] " Sebastian Andrzej Siewior
2023-08-04 16:23       ` Sohil Mehta
2023-08-08 17:14       ` [tip: x86/microcode] " tip-bot2 for Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f31f938-cd4f-bb1b-d44d-57adabf62c51@intel.com \
    --to=sohil.mehta@intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®