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

From: Waiman Long
Date: Thu Aug 18 2016 - 20:59:01 EST


On 08/18/2016 10:14 AM, Peter Zijlstra wrote:
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 ?

I don't think there is any realistic chance that starvation will happen on a uniprocessor system with preemptible kernel. So I don't think that is necessary.

Cheers,
Longman