Skip to contentSkip to conversation

wait: Relate wait_event_cmd() to its userspace equivalence

PATCH In review Håkon Bugge 1 participant 2 messages Jun 27, 2025 – Jul 21, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wait: Relate wait_event_cmd() to its userspace equivalence

Relate wait_event_cmd() to userspace's pthread_cond_wait(). This because when searching for functionality comparable to pthread_cond_wait(), it is very hard to find wait_event_cmd().

--

v1 -> v2:
* Split original patch into two
* Wordsmithing as suggested by Matthew

---
 include/linux/wait.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/wait.h +8 -0
index 965a19809c7e5..62df98193a3a7 100644
@@ -469,6 +469,14 @@ do {										\
  *
  * wake_up() has to be called after changing any variable that could
  * change the result of the wait condition.
+ *
+ * This is the kernel's polymorphic implementation of userspace's
+ * pthread_cond_wait().
+ *
+ * When calling this function, cmd1 is typically a lock-release call
+ * and cmd2 a lock-acquire call. The locking primitive can be chosen,
+ * contrary to pthread_cond_wait(), where the locking type is cast in
+ * stone and is a pthread_mutex_t.
  */
 #define wait_event_cmd(wq_head, condition, cmd1, cmd2)				\
 do {										\
Signature · 1 line
2.43.5
#1 lore raw
Quoted 9 lines · Håkon Bugge

Relate wait_event_cmd() to userspace's pthread_cond_wait(). This because when searching for functionality comparable to pthread_cond_wait(), it is very hard to find wait_event_cmd().

A gentle ping on this one.

Thxs, Håkon

Quoted 32 lines

--

v1 -> v2:
* Split original patch into two
* Wordsmithing as suggested by Matthew
---
include/linux/wait.h | 8 ++++++++

1 file changed, 8 insertions(+)
include/linux/wait.h +8 -0
index 965a19809c7e5..62df98193a3a7 100644
@@ -469,6 +469,14 @@ do { \
 *
 * wake_up() has to be called after changing any variable that could
 * change the result of the wait condition.
+ *
+ * This is the kernel's polymorphic implementation of userspace's
+ * pthread_cond_wait().
+ *
+ * When calling this function, cmd1 is typically a lock-release call
+ * and cmd2 a lock-acquire call. The locking primitive can be chosen,
+ * contrary to pthread_cond_wait(), where the locking type is cast in
+ * stone and is a pthread_mutex_t.
 */
 #define wait_event_cmd(wq_head, condition, cmd1, cmd2) \
 do { \
Signature · 1 line
2.43.5