Re: [PATCH -tip 1/3] x86/fsgsbase: Remove unnecessary "memory" clobbers from FS/GS base accessors
From: Uros Bizjak
Date: Tue Mar 10 2026 - 14:28:13 EST
On Tue, Mar 10, 2026 at 7:11 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Tue, Mar 10, 2026 at 04:48:34PM +0100, Uros Bizjak wrote:
> > On 3/10/26 11:27, Peter Zijlstra wrote:
> >
> > On Tue, Mar 10, 2026 at 09:21:22AM +0100, Uros Bizjak wrote:
> >
> > >> The rdfsbase() and rdgsbase() helpers currently include a "memory" clobber
> > >> in their inline assembly definitions. However, the RDFSBASE and RDGSBASE
> > >> instructions only read the FS/GS base MSRs into a general-purpose register
> > >> and do not access memory. As such, the "memory" clobber is unnecessary.
> > >
> > > The point isn't that this accesses memory, but that prior or later
> > > accesses would end up at different memory locations (as would happen
> > > when setting the per-cpu segment.
> >
> > Please note that the above comment is talking about rd[fs,gs]base
> > instructions that only *read* the segment register into GPR. They do
> > not affect memory in any way and can be scheduled anywhere, but they
> > should not be scheduled over segment register *setting* instructions.
>
> Yes, we are in violent agreement :-) I just took issue with the way your
> changelog expressed things. The memory clobber isn't about the asm
> accessing memory or not, it is about adding a scheduling constraint.
I see. I will add this detail to a v2 ChangeLog with a remark that
"asm volatile" alone is enough to prevent unwanted scheduling
(something like the explanation in patch 2/3 which explains in more
detail why "asm volatile" should be used instead of memory clobber).
> > > Anyway, aside from that nit, yes these 3 patches look good to me.
> >
> > Can this be considered as Acked-by: from your side?
>
> Yep.
Thanks,
Uros.