From: Peter Zijlstra <peterz@infradead.org>
To: Yao Zi <me@ziyao.cc>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Randy Dunlap <rdunlap@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] x86/locking: Use sfence for wmb() if SSE is available
Date: Mon, 3 Aug 2026 08:22:01 +0200 [thread overview]
Message-ID: <20260803062201.GT49951@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260801182953.15069-1-me@ziyao.cc>
On Sat, Aug 01, 2026 at 06:29:53PM +0000, Yao Zi wrote:
> When adding cc clobber to wmb()'s definition, the alternative()
> condition to use sfence was incorrectly raised from X86_FEATURE_XMM to
> X86_FEATURE_XMM2.
>
> Restore the correct constraint for potential better performance on
> machines without SSE2.
So Google tells me that SSE was introduced with P-III, while SSE2 was
introduced with P4, so this affects only P-III.
Anything earlier won't care, and anything later will have DTRT.
I suppose we can do this, for those few people that still care about
P-III... *sigh*.
> Fixes: bd922477d935 ("locking/x86: Add cc clobber for ADDL")
> Signed-off-by: Yao Zi <me@ziyao.cc>
> Cc: stable@vger.kernel.org
> ---
> arch/x86/include/asm/barrier.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
> index b0096b5645a9..e0e59da15748 100644
> --- a/arch/x86/include/asm/barrier.h
> +++ b/arch/x86/include/asm/barrier.h
> @@ -17,7 +17,7 @@
> #define rmb() asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "lfence", \
> X86_FEATURE_XMM2) ::: "memory", "cc")
> #define wmb() asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "sfence", \
> - X86_FEATURE_XMM2) ::: "memory", "cc")
> + X86_FEATURE_XMM) ::: "memory", "cc")
> #else
> #define __mb() asm volatile("mfence":::"memory")
> #define __rmb() asm volatile("lfence":::"memory")
> --
> 2.54.0
>
prev parent reply other threads:[~2026-08-03 6:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-01 18:29 [PATCH] x86/locking: Use sfence for wmb() if SSE is available Yao Zi
2026-08-03 6:22 ` Peter Zijlstra [this message]
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=20260803062201.GT49951@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=me@ziyao.cc \
--cc=mingo@redhat.com \
--cc=rdunlap@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--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