Skip to contentSkip to conversation

locking/rtmutex: Fix misleading comment

PATCH Applied Peter Zijlstra 3 participants 3 messages Oct 8, 2024 – Oct 24, 2024 Locking primitives

lore
Share & tools
lore

Peter Zijlstra

author maintainer
#0 lore raw

PATCH 1/1 locking/rtmutex: Fix misleading comment

Going through the RCU-boost and rtmutex code, I ran into this utterly confusing comment. Fix it to avoid confusing future readers.

---

kernel/locking/rtmutex_api.c +1 -1
index a6974d044593..587ede8073c0 100644
@@ -175,7 +175,7 @@ bool __sched __rt_mutex_futex_unlock(struct rt_mutex_base *lock,
 	}
 
 	/*
-	 * We've already deboosted, mark_wakeup_next_waiter() will
+	 * This will deboost, mark_wakeup_next_waiter() will
 	 * retain preempt_disabled when we drop the wait_lock, to
 	 * avoid inversion prior to the wakeup.  preempt_disable()
 	 * therein pairs with rt_mutex_postunlock().
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Peter Zijlstra

Going through the RCU-boost and rtmutex code, I ran into this utterly confusing comment. Fix it to avoid confusing future readers.

Correct.

kernel/locking/rtmutex_api.c bool __sched __rt_mutex_futex_unlock(struct rt_mutex_base *lock, · line 178

Quoted 12 lines

---

kernel/locking/rtmutex_api.c +1 -1
index a6974d044593..587ede8073c0 100644
@@ -175,7 +175,7 @@ bool __sched __rt_mutex_futex_unlock(struct rt_mutex_base *lock,
 	}
 
 	/*
-	 * We've already deboosted, mark_wakeup_next_waiter() will
+	 * This will deboost, mark_wakeup_next_waiter() will

+ * mark_wakeup_next_waiter() will deboost and

kernel/locking/rtmutex_api.c bool __sched __rt_mutex_futex_unlock(struct rt_mutex_base *lock, · line 181

Quoted 3 lines
kernel/locking/rtmutex_api.c +0 -0
 	 * retain preempt_disabled when we drop the wait_lock, to
 	 * avoid inversion prior to the wakeup.  preempt_disable()
 	 * therein pairs with rt_mutex_postunlock().

This could make it obvious that mark_wakeup_next_waiter() does all the things.

Sebastian

merge bot Applied
#2 lore raw
In reply to Peter Zijlstra
The following commit has been merged into the locking/core branch of tip:

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     d12b802f183667d4c28589314c99c380a458d57e
Gitweb:        https://git.kernel.org/tip/d12b802f183667d4c28589314c99c380a458d57e
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Tue, 08 Oct 2024 11:26:06 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 24 Oct 2024 23:03:30 +02:00

locking/rtmutex: Fix misleading comment

Going through the RCU-boost and rtmutex code, I ran into this utterly confusing comment. Fix it to avoid confusing future readers.

[ tglx: Wordsmithed the comment ]

---
 kernel/locking/rtmutex_api.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/locking/rtmutex_api.c +4 -4
index a6974d0..7e79258 100644
@@ -175,10 +175,10 @@ bool __sched __rt_mutex_futex_unlock(struct rt_mutex_base *lock,
 	}
 
 	/*
-	 * We've already deboosted, mark_wakeup_next_waiter() will
-	 * retain preempt_disabled when we drop the wait_lock, to
-	 * avoid inversion prior to the wakeup.  preempt_disable()
-	 * therein pairs with rt_mutex_postunlock().
+	 * mark_wakeup_next_waiter() deboosts and retains preemption
+	 * disabled when dropping the wait_lock, to avoid inversion prior
+	 * to the wakeup.  preempt_disable() therein pairs with the
+	 * preempt_enable() in rt_mutex_postunlock().
 	 */
 	mark_wakeup_next_waiter(wqh, lock);