[PATCH RESEND v7 6/6] arm64: futex: support futex with FEAT_LSUI
Catalin Marinas
catalin.marinas at arm.com
Fri Sep 12 10:16:09 PDT 2025
On Thu, Sep 11, 2025 at 04:22:24PM +0100, Will Deacon wrote:
> On Sat, Aug 16, 2025 at 04:19:29PM +0100, Yeoreum Yun wrote:
> > +static __always_inline int
> > +__lsui_futex_atomic_eor(int oparg, u32 __user *uaddr, int *oval)
> > +{
> > + unsigned int loops = LLSC_MAX_LOOPS;
> > + int ret, oldval, tmp;
> > +
> > + uaccess_ttbr0_enable();
> > + /*
> > + * there are no ldteor/stteor instructions...
> > + */
>
> *sigh*
>
> Were these new instructions not added with futex in mind?
I guess it was _most_ of the futex.
> I wonder whether CAS would be better than exclusives for xor...
I was first thinking we could share some of the code with
__futex_cmpxchg() but...
> > +static __always_inline int
> > +__lsui_futex_cmpxchg(u32 __user *uaddr, u32 oldval, u32 newval, u32 *oval)
> > +{
> > + int ret = 0;
> > + unsigned int loops = LLSC_MAX_LOOPS;
> > + u32 val, tmp;
> > +
> > + uaccess_ttbr0_enable();
> > + /*
> > + * cas{al}t doesn't support word size...
> > + */
>
> What about just aligning down and doing a 64-bit cas in that case?
I think it gets more complicated. Here we get the oldval from the
caller, so no need to do a read. With CAS, we'd need to read the full
64-bit, replace half of it with oldval and newval just to be able to do
the operation. On top of this, we need to check which half of the 64-bit
value. I think it to hairy for little benefit.
--
Catalin
More information about the linux-arm-kernel
mailing list