Re: [RFC PATCH 7/9] um: nommu: add SMP futex operations

Johannes Berg <[email protected]> Mon, 20 Jul 2026 21:10:01 +0200
Newsgroups org.infradead.lists.linux-um
Message-ID <[email protected]>
On Mon, 2026-07-20 at 21:06 +0200, Johannes Berg wrote:
> On Mon, 2026-07-20 at 20:26 +0200, Johannes Berg wrote:
> >=20
> > +static inline int
> > +arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *=
uaddr)
> > +{
> > +	u32 oldval, newval;
> > +	u32 *p =3D (u32 __force *)uaddr;
> > +
> > +	do {
> > +		oldval =3D READ_ONCE(*p);
> > +
> > +		switch (op) {
> > +		case FUTEX_OP_SET:
> > +			newval =3D oparg;
> > +			break;
> > +		case FUTEX_OP_ADD:
> > +			newval =3D oldval + oparg;
> > +			break;
> > +		case FUTEX_OP_OR:
> > +			newval =3D oldval | oparg;
> > +			break;
> > +		case FUTEX_OP_ANDN:
> > +			newval =3D oldval & ~oparg;
> > +			break;
> > +		case FUTEX_OP_XOR:
> > +			newval =3D oldval ^ oparg;
> > +			break;
> > +		default:
> > +			return -ENOSYS;
> > +		}
> > +	} while (!try_cmpxchg(p, &oldval, newval));
> > +
> > +	*oval =3D oldval;
>=20
> Wait ... this is also garbage, it should just be the switch() and then
>=20
> 	*oval =3D cmpxchg(p, oldval, newval);
>=20
> not the loop...

Err, no. But our uaccess.c implementation here also seems wrong and
should be more like this one?

OK I'm confused, but I think we need to clean up uaccess.c before
implementing this for real...


johannes