Re: [PATCH manpages] membarrier.2: New membarrier commands introduced in 4.16

2018-04-12 Thread Michael Kerrisk (man-pages)
On 04/12/2018 02:20 PM, Mathieu Desnoyers wrote:
> - On Apr 12, 2018, at 7:42 AM, Michael Kerrisk mtk.manpa...@gmail.com 
> wrote:
> 
> Hi Michael,
> 
> [...]
>>
>> I have applied the above patch, and done quite a bit of tweaking, and
>> pushed the results to the git repo.
>>
>> I would be grateful if you would read the entire manual page as it
>> currently stands, to see if anything needs improving. I isolated some
>> of the more significant changes into a simple patch, shown below, and
>> especially I'd like your confirmation that all of those changes are
>> okay.
> 
> Thanks for applying my membarrier man pages updates. I've reviewed the
> result and it is all good.

Thanks Mathieu!

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/


Re: [PATCH manpages] membarrier.2: New membarrier commands introduced in 4.16

2018-04-12 Thread Mathieu Desnoyers
- On Apr 12, 2018, at 7:42 AM, Michael Kerrisk mtk.manpa...@gmail.com wrote:

Hi Michael,

[...]
> 
> I have applied the above patch, and done quite a bit of tweaking, and
> pushed the results to the git repo.
> 
> I would be grateful if you would read the entire manual page as it
> currently stands, to see if anything needs improving. I isolated some
> of the more significant changes into a simple patch, shown below, and
> especially I'd like your confirmation that all of those changes are
> okay.

Thanks for applying my membarrier man pages updates. I've reviewed the
result and it is all good.

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


Re: [PATCH manpages] membarrier.2: New membarrier commands introduced in 4.16

2018-04-12 Thread Michael Kerrisk (man-pages)
Hello Mathieu,

On 12 February 2018 at 20:55, Mathieu Desnoyers
 wrote:
> Document the following membarrier commands introduced in 4.16:
> - MEMBARRIER_CMD_GLOBAL_EXPEDITED (the old enum label
>   MEMBARRIER_CMD_SHARED is now an alias to preserve header backward
>   compatibility),
> - MEMBARRIER_CMD_GLOBAL_EXPEDITED,
> - MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED,
> - MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE,
> - MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE.
>
> Signed-off-by: Mathieu Desnoyers 
> CC: Michael Kerrisk 
> CC: Ingo Molnar 
> CC: Peter Zijlstra 
> CC: Thomas Gleixner 
> ---
>  man2/membarrier.2 | 73 
> ++-
>  1 file changed, 62 insertions(+), 11 deletions(-)
>
> diff --git a/man2/membarrier.2 b/man2/membarrier.2
> index c47bc875a..e878301ca 100644
> --- a/man2/membarrier.2
> +++ b/man2/membarrier.2
> @@ -80,7 +80,7 @@ This command is always supported (on kernels where
>  .BR membarrier ()
>  is provided).
>  .TP
> -.B MEMBARRIER_CMD_SHARED
> +.B MEMBARRIER_CMD_GLOBAL " (since Linux 4.16)"
>  Ensure that all threads from all processes on the system pass through a
>  state where all memory accesses to user-space addresses match program
>  order between entry to and return from the
> @@ -88,7 +88,30 @@ order between entry to and return from the
>  system call.
>  All threads on the system are targeted by this command.
>  .TP
> -.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED " (since Linux 4.14)"
> +.B MEMBARRIER_CMD_GLOBAL_EXPEDITED " (since Linux 4.16)"
> +Execute a memory barrier on all running threads of all processes which
> +previously registered with
> +.BR MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED .
> +Upon return from system call, the caller thread is ensured that all
> +running threads have passed through a state where all memory accesses to
> +user-space addresses match program order between entry to and return
> +from the system call (non-running threads are de facto in such a state).
> +This only covers threads from processes which registered with
> +.BR MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED .
> +Given that registration is about the intent to receive the barriers, it
> +is valid to invoke
> +.BR MEMBARRIER_CMD_GLOBAL_EXPEDITED
> +from a non-registered process.
> +.IP
> +The "expedited" commands complete faster than the non-expedited ones;
> +they never block, but have the downside of causing extra overhead.
> +.TP
> +.B MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED " (since Linux 4.16)"
> +Register the process intent to receive
> +.BR MEMBARRIER_CMD_GLOBAL_EXPEDITED
> +memory barriers.
> +.TP
> +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED " (since Linux 4.14)"
>  Execute a memory barrier on each running thread belonging to the same
>  process as the current thread.
>  Upon return from system call, the calling
> @@ -103,9 +126,29 @@ they never block, but have the downside of causing extra 
> overhead.
>  A process needs to register its intent to use the private
>  expedited command prior to using it.
>  .TP
> -.BR MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED " (since Linux 4.14)"
> +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED " (since Linux 4.14)"
>  Register the process's intent to use
> -.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED .
> +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED .
> +.TP
> +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE " (since Linux 4.16)"
> +In addition to provide memory ordering guarantees described in
> +.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED ,
> +ensure the caller thread, upon return from system call, that all its
> +running threads siblings have executed a core serializing instruction.
> +This only covers threads from the same process as the caller thread.
> +The "expedited" commands complete faster than the non-expedited ones,
> +they never block, but have the downside of causing extra overhead. A
> +process needs to register its intent to use the private expedited sync
> +core command prior to using it.
> +.TP
> +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE " (since Linux 4.16)"
> +Register the process intent to use
> +.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE .
> +.TP
> +.B MEMBARRIER_CMD_SHARED
> + Alias to
> +.BR MEMBARRIER_CMD_GLOBAL .
> +Provided for header backward compatibility.
>  .PP
>  The
>  .I flags
> @@ -137,10 +180,14 @@ The pair ordering is detailed as (O: ordered, X: not 
> ordered):
>  On success, the
>  .B MEMBARRIER_CMD_QUERY
>  operation returns a bit mask of supported commands, and the
> -.B MEMBARRIER_CMD_SHARED ,
> +.B MEMBARRIER_CMD_GLOBAL ,
> +.B MEMBARRIER_CMD_GLOBAL_EXPEDITED ,
> +.B MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED ,
>  .B MEMBARRIER_CMD_PRIVATE_EXPEDITED ,
> -and
>  .B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED ,
> +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE ,
> +and
> +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
>  operations return zero.
>  On error, \-1 is returned,
>  and
> @@ -163,10 +210,14 @@ set to 0, error handling is required only for the first 
> call to
>  is inva