public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Carlos O'Donell <carlos@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org,
	"Alejandro Colomar" <alx@kernel.org>,
	"André Almeida" <andrealmeid@igalia.com>,
	"Darren Hart" <dvhart@infradead.org>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"Waiman Long" <longman@redhat.com>
Subject: Re: [PATCH 4/4] man/man2/futex.2: Add a pointer to Linux' memory-barrier
Date: Mon, 8 Sep 2025 16:21:28 +0200	[thread overview]
Message-ID: <20250908142128.nciFBdjQ@linutronix.de> (raw)
In-Reply-To: <1b4b0a00-3e80-49a9-bee4-2c7a90e85941@redhat.com>

On 2025-08-29 13:46:19 [-0400], Carlos O'Donell wrote:
> On 8/29/25 12:02 PM, Sebastian Andrzej Siewior wrote:
> > The "totally ordered with respect to concurrent operations" part refers
> > to memory ordering/ atomic update and has nothing to do with the inner
> > workings of the FUTEX code. It simply tries to express that the futex
> > operation will compare the supplied argument with that is written in
> > memory.
> > 
> > This might be a tad too verbose but then there is a fixme asking for
> > details on the sychronisation. Maybe a pointer to the memory barriers is
> > enough in terms of the required synchronisaton. Assuming this is related
> > to the memory value and not the futex internal synchronisation.
> > 
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > ---
> >   man/man2/futex.2 | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/man/man2/futex.2 b/man/man2/futex.2
> > index 027e91b826bf1..fe4a239c3812c 100644
> > --- a/man/man2/futex.2
> > +++ b/man/man2/futex.2
> > @@ -84,16 +84,14 @@ on the same futex word.
> >   .\"     would be sufficient? Or perhaps for this manual, "serialized" would
> >   .\"     be sufficient, with a footnote regarding "totally ordered" and a
> >   .\"     pointer to the memory-barrier documentation?
> > +Please see
> > +.IR https://docs.kernel.org/\:next/\:core-api/\:wrappers/\:memory-barriers.html
> > +for the definition of atomic operations and memory ordering.
> 
> This seems out of place with the flow of the rest of the text.
> 
> I suggest adding this as a foot note.
> 
> >   Thus, the futex word is used to connect the synchronization in user space
> >   with the implementation of blocking by the kernel.
> >   Analogously to an atomic
> >   compare-and-exchange operation that potentially changes shared memory,
> >   blocking via a futex is an atomic compare-and-block operation.
> > -.\" FIXME(Torvald Riegel):
> > -.\" Eventually we want to have some text in NOTES to satisfy
> > -.\" the reference in the following sentence
> > -.\"     See NOTES for a detailed specification of
> > -.\"     the synchronization semantics.
> 
> I think it is acceptable to link to Documentation/memory-barriers.rst, but
> the truth is that this document doesn't yet provide all the notes required
> to answer the questions wrt a futex. Fundamentally we use spinlocks for futexes
> (and some arches use more like parisc), and spinlocks are covered in
> "Implicit Kernel Memory Barrires", there isn't any direct connection between
> them in the text (and doing so would create a design requirement).

There might be two things to it. The spinlocks are used in kernel and
synchronize the kernel internal state. The memory barriers might be
important in regard to how the futex word should be updated atomically.

> >   .P
> >   One use of futexes is for implementing locks.
> >   The state of the lock (i.e., acquired or not acquired)

Sebastian

  reply	other threads:[~2025-09-08 14:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 16:01 [PATCH 0/4] sched.7 and small futex.2 updates Sebastian Andrzej Siewior
2025-08-29 16:01 ` [PATCH 1/4] man/man7/sched.7: Update the real-time section Sebastian Andrzej Siewior
2025-09-02  7:24   ` Juri Lelli
2025-09-08 13:59     ` Sebastian Andrzej Siewior
2025-08-29 16:01 ` [PATCH 2/4] man/man7/sched.7: Update the documentation references Sebastian Andrzej Siewior
2025-08-30  7:28   ` G. Branden Robinson
2025-09-08 13:51     ` Sebastian Andrzej Siewior
2025-09-08 14:11       ` G. Branden Robinson
2025-09-08 14:25         ` Sebastian Andrzej Siewior
2025-09-08 14:29           ` G. Branden Robinson
2025-09-08 14:34             ` Sebastian Andrzej Siewior
2025-09-08 15:02               ` G. Branden Robinson
2025-09-08 15:44                 ` Sebastian Andrzej Siewior
2025-09-08 16:47                   ` G. Branden Robinson
2025-08-29 16:01 ` [PATCH 3/4] man/man2/futex.2: Recycle two gmane URLs Sebastian Andrzej Siewior
2025-08-29 16:43   ` Carlos O'Donell
2025-08-29 17:39     ` Sebastian Andrzej Siewior
2025-08-29 17:54       ` Carlos O'Donell
2025-08-31  8:48   ` Alejandro Colomar
2025-08-29 16:02 ` [PATCH 4/4] man/man2/futex.2: Add a pointer to Linux' memory-barrier Sebastian Andrzej Siewior
2025-08-29 17:46   ` Carlos O'Donell
2025-09-08 14:21     ` Sebastian Andrzej Siewior [this message]
2025-08-30  7:33   ` G. Branden Robinson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250908142128.nciFBdjQ@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=alx@kernel.org \
    --cc=andrealmeid@igalia.com \
    --cc=carlos@redhat.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox