Re: [RFC PATCH v2 4/4] selftests/rseq: Implement rseq_mutex test program

From: Thomas Gleixner
Date: Thu Sep 28 2023 - 15:55:31 EST


On Mon, May 29 2023 at 15:14, Mathieu Desnoyers wrote:
> +static void rseq_lock_slowpath(struct rseq_mutex *lock)
> +{
> + int i = 0;
> +
> + for (;;) {
> + struct rseq_abi_sched_state *expected = NULL, *self = rseq_get_sched_state(rseq_get_abi());
> +
> + if (__atomic_compare_exchange_n(&lock->owner, &expected, self, false,
> + __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
> + break;
> + //TODO: use rseq critical section to protect dereference of owner thread's
> + //rseq_abi_sched_state, combined with rseq fence at thread reclaim.
> + if ((RSEQ_READ_ONCE(expected->state) & RSEQ_ABI_SCHED_STATE_FLAG_ON_CPU) &&

For robust and PI futexes the futex value is an ABI between kernel and
user space. Sure, this is only meant for demonstration, but it's the
wrong direction.

Thanks,

tglx