RE: [PATCH] Fix data race in mark_rt_mutex_waiters
From: David Laight
Date: Fri Jan 20 2023 - 11:58:29 EST
From: Peter Zijlstra
> Sent: 20 January 2023 16:23
...
> > do {
> > - owner = *p;
> > + owner = READ_ONCE(*p);
> > } while (cmpxchg_relaxed(p, owner,
> > owner | RT_MUTEX_HAS_WAITERS) != owner);
> >
>
> Can't we replace the whole of that function with:
>
> set_bit(0, (unsigned long *)&lock->owner);
>
> ?
If you need the cast then probably not...
There really ought to be a compile-time test (somehow)
that set_bit() is only used on large bit arrays.
OTOH atomic_or32/64() and atomic_and32/64() might use
usable in many places.
On x86 I doubt it makes much difference whether you use
'bis' or 'lock or'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)