Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled

Peter Zijlstra
2016-08-18T14:49:25Z

On Wed, Aug 10, 2016 at 11:44:08AM -0700, Jason Low wrote:
> diff --git a/include/linux/mutex.h b/include/linux/mutex.h
> index 2cb7531..5643a233 100644
> --- a/include/linux/mutex.h
> +++ b/include/linux/mutex.h
> @@ -57,6 +57,8 @@ struct mutex {
> #endif
> #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
> struct optimistic_spin_queue osq; /* Spinner MCS lock */
> +#elif defined(CONFIG_SMP)
> + bool yield_to_waiter; /* Prevent starvation when spinning disabled */
> #endif
> #ifdef CONFIG_DEBUG_MUTEXES
> void *magic;

Isn't this also possible on !SMP && PREEMPT ?