linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] docs/memory-barriers.txt: Add wait_event_cmd() and wait_event_exclusive_cmd()
@ 2025-06-26 14:37 Håkon Bugge
  2025-06-26 15:17 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Håkon Bugge @ 2025-06-26 14:37 UTC (permalink / raw)
  To: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra, Boqun Feng,
	Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
	Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
	Jonathan Corbet
  Cc: Håkon Bugge, linux-kernel, linux-arch, lkmm, linux-doc

Add said functions to the documentation and relate them to userspace's
pthread_cond_wait(). The latter because when searching for
functionality comparable to pthread_cond_wait(), it is very hard to
find wait_event_cmd().

Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
---
 Documentation/memory-barriers.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 93d58d9a428b8..d721e9be5a4f5 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -2192,6 +2192,8 @@ interpolate the memory barrier in the right place:
 	wait_event_timeout();
 	wait_on_bit();
 	wait_on_bit_lock();
+	wait_event_cmd();
+	wait_event_exclusive_cmd();
 
 
 Secondly, code that performs a wake up normally follows something like this:
@@ -2296,6 +2298,15 @@ and the waker should do:
 	event_indicated = 1;
 	wake_up(&event_wait_queue);
 
+Note that the wait_event_cmd() and wait_event_exclusive_cmd() are the
+kernel's polymorphic implementation of userspace's
+pthread_cond_wait().
+
+Using wait_event_cmd() or wait_event_exclusive_cmd(), 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.
+
 
 MISCELLANEOUS FUNCTIONS
 -----------------------
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] docs/memory-barriers.txt: Add wait_event_cmd() and wait_event_exclusive_cmd()
  2025-06-26 14:37 [PATCH 1/1] docs/memory-barriers.txt: Add wait_event_cmd() and wait_event_exclusive_cmd() Håkon Bugge
@ 2025-06-26 15:17 ` Matthew Wilcox
  2025-06-26 16:18   ` Haakon Bugge
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2025-06-26 15:17 UTC (permalink / raw)
  To: Håkon Bugge
  Cc: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra, Boqun Feng,
	Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
	Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
	Jonathan Corbet, linux-kernel, linux-arch, lkmm, linux-doc

On Thu, Jun 26, 2025 at 04:37:05PM +0200, Håkon Bugge wrote:
> Add said functions to the documentation and relate them to userspace's
> pthread_cond_wait(). The latter because when searching for
> functionality comparable to pthread_cond_wait(), it is very hard to
> find wait_event_cmd().

Would it not go better in the kernel-doc for wait_event_cmd() in
include/linux/wait.h?

>  
> +Note that the wait_event_cmd() and wait_event_exclusive_cmd() are the
> +kernel's polymorphic implementation of userspace's
> +pthread_cond_wait().

Pet peeve: "Note that" adds nothing to this sentence.  You can just
write:

The wait_event_cmd() and wait_event_exclusive_cmd() functions are the
kernel's polymorphic implementation of userspace's pthread_cond_wait().

> +Using wait_event_cmd() or wait_event_exclusive_cmd(), 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.
> +
>  
>  MISCELLANEOUS FUNCTIONS
>  -----------------------
> -- 
> 2.43.5
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] docs/memory-barriers.txt: Add wait_event_cmd() and wait_event_exclusive_cmd()
  2025-06-26 15:17 ` Matthew Wilcox
@ 2025-06-26 16:18   ` Haakon Bugge
  0 siblings, 0 replies; 3+ messages in thread
From: Haakon Bugge @ 2025-06-26 16:18 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra, Boqun Feng,
	Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
	Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
	Jonathan Corbet, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, lkmm@lists.linux.dev,
	linux-doc@vger.kernel.org



> On 26 Jun 2025, at 17:17, Matthew Wilcox <willy@infradead.org> wrote:
> 
> On Thu, Jun 26, 2025 at 04:37:05PM +0200, Håkon Bugge wrote:
>> Add said functions to the documentation and relate them to userspace's
>> pthread_cond_wait(). The latter because when searching for
>> functionality comparable to pthread_cond_wait(), it is very hard to
>> find wait_event_cmd().
> 
> Would it not go better in the kernel-doc for wait_event_cmd() in
> include/linux/wait.h?

What about both? The list with wait_foo_bars() in Documentation/memory-barriers.txt misses wait_event_cmd() and wait_event_exclusive_cmd().

But my prosaic explanation could very well go into include/linux/wait.h

>> +Note that the wait_event_cmd() and wait_event_exclusive_cmd() are the
>> +kernel's polymorphic implementation of userspace's
>> +pthread_cond_wait().
> 
> Pet peeve: "Note that" adds nothing to this sentence.  You can just
> write:
> 
> The wait_event_cmd() and wait_event_exclusive_cmd() functions are the
> kernel's polymorphic implementation of userspace's pthread_cond_wait().

Me blushing! +1

Thxs, Håkon

> 
>> +Using wait_event_cmd() or wait_event_exclusive_cmd(), 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.
>> +
>> 
>> MISCELLANEOUS FUNCTIONS
>> -----------------------
>> -- 
>> 2.43.5
>> 
>> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-26 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 14:37 [PATCH 1/1] docs/memory-barriers.txt: Add wait_event_cmd() and wait_event_exclusive_cmd() Håkon Bugge
2025-06-26 15:17 ` Matthew Wilcox
2025-06-26 16:18   ` Haakon Bugge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).