Re: [PATCH 1/4] sched/wakeup: Strengthen current_save_and_set_rtlock_wait_state()

From: Sebastian Andrzej Siewior
Date: Fri Sep 10 2021 - 08:45:35 EST


On 2021-09-09 12:59:16 [+0200], Peter Zijlstra wrote:
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -253,22 +254,24 @@ struct task_group;
> */
> #define current_save_and_set_rtlock_wait_state() \
> do { \
> - lockdep_assert_irqs_disabled(); \
> - raw_spin_lock(&current->pi_lock); \
> + unsigned long flags; /* may shadow */ \
could we haz __flags so no shadow?

> + \
> + raw_spin_lock_irqsave(&current->pi_lock, flags); \
> current->saved_state = current->__state; \
> debug_rtlock_wait_set_state(); \
> - WRITE_ONCE(current->__state, TASK_RTLOCK_WAIT); \
> - raw_spin_unlock(&current->pi_lock); \
> + smp_store_mb(current->__state, TASK_RTLOCK_WAIT); \
> + raw_spin_unlock_irqrestore(&current->pi_lock, flags); \

Sebastian