Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crash with PREEMPT_RT on aarch64 machine
How about this? - The fast path is easy… - The slow path first sets the WAITER bits (mark_rt_mutex_waiters()) so I made that one _acquire so that it is visible by the unlocker forcing everyone into slow path. - If the lock is acquired, then the owner is written via rt_mutex_set_owner(). This happens under wait_lock so it is serialized and so a WRITE_ONCE() is used to write the final owner. I replaced it with a cmpxchg_acquire() to have the owner there. Not sure if I shouldn't make this as you put it: | e.g. by making use of dependency ordering where it already exists. The other (locking) CPU needs to see the owner not only the WAITER bit. I'm not sure if this could be replaced with smp_store_release(). - After the whole operation completes, fixup_rt_mutex_waiters() cleans the WAITER bit and I kept the _acquire semantic here. Now looking at it again, I don't think that needs to be done since that shouldn't be set here. - There is rtmutex_spin_on_owner() which (as the name implies) spins on the owner as long as it active. It obtains it via READ_ONCE() and I'm not sure if any memory barrier is needed. Worst case is that it will spin while owner isn't set if it observers a stale value. - The unlock path first clears the waiter bit if there are no waiters recorded (via simple assignments under the wait_lock (every locker will fail with the cmpxchg_acquire() and go for the wait_lock)) and then finally drop it via rt_mutex_cmpxchg_release(,, NULL). Should there be a wait, it will just store the WAITER bit with smp_store_release() (setting the owner is NULL but the WAITER bit forces everyone into the slow path). - Added rt_mutex_set_owner_pi() which does simple assignment. This is used from the futex code and here everything happens under a lock. - I added a smp_load_acquire() to rt_mutex_base_is_locked() since I *think* want to observe a real waiter and not something stale. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- Loading branch information