Re: [GIT pull] x86/urgent for v6.11-rc3

From: Qiuxu Zhuo
Date: Mon Aug 12 2024 - 23:28:21 EST


> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> To: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx
> Subject: Re: [GIT pull] x86/urgent for v6.11-rc3
>
> On Sun, Aug 11 2024 at 11:07, Linus Torvalds wrote:
> [...]
> > So i think that static_branch_likely() should have been changed to a
> > static_branch_unlikely() too, but it's possible that I've just
> > confused myself.
>
> You are right. It creates a branch for the !virt_lock case.
>
> > Anyway, somebody should double-check me.
> >
> > I doubt it actually matters, since I think this all is fundamentally
> > just in the slow-path, so the "do a branch or a no-op" is likely
> > entirely in the noise even if I followed the code right. But it looked
> > off to me.
>
> It is off and yes it won't matter much in the slowpath maze.

static_branch_unlikely() matches that 'virt_spin_lock_key' is set to false
in default after the commit,

e639222a5119 ("x86/paravirt: Fix incorrect virt spinlock setting on bare metal")

although it offers little performance benefit since it is in the slow path.

Thomas, do you think it's worth making a patch to convert static_branch_likely()
to static_branch_unlikely() for this check, as suggested by Linus?
If so, I can assist with this.

Thanks!
-Qiuxu