From: Florian Weimer <fweimer@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"André Almeida" <andrealmeid@collabora.com>,
linux-kernel@vger.kernel.org, kernel@collabora.com,
krisman@collabora.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org, rostedt@goodmis.org,
ryao@gentoo.org, dvhart@infradead.org, mingo@redhat.com,
z.figura12@gmail.com, steven@valvesoftware.com,
steven@liquorix.net, malteskarupke@web.de, carlos@redhat.com,
adhemerval.zanella@linaro.org, libc-alpha@sourceware.org
Subject: Re: 'simple' futex interface [Was: [PATCH v3 1/4] futex: Implement mechanism to wait on any of several futexes]
Date: Tue, 03 Mar 2020 14:00:12 +0100 [thread overview]
Message-ID: <87pndth9ur.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <20200303120050.GC2596@hirez.programming.kicks-ass.net> (Peter Zijlstra's message of "Tue, 3 Mar 2020 13:00:50 +0100")
* Peter Zijlstra:
> So how about we introduce new syscalls:
>
> sys_futex_wait(void *uaddr, unsigned long val, unsigned long flags, ktime_t *timo);
>
> struct futex_wait {
> void *uaddr;
> unsigned long val;
> unsigned long flags;
> };
> sys_futex_waitv(struct futex_wait *waiters, unsigned int nr_waiters,
> unsigned long flags, ktime_t *timo);
>
> sys_futex_wake(void *uaddr, unsigned int nr, unsigned long flags);
>
> sys_futex_cmp_requeue(void *uaddr1, void *uaddr2, unsigned int nr_wake,
> unsigned int nr_requeue, unsigned long cmpval, unsigned long flags);
>
> Where flags:
>
> - has 2 bits for size: 8,16,32,64
> - has 2 more bits for size (requeue) ??
> - has ... bits for clocks
> - has private/shared
> - has numa
What's the actual type of *uaddr? Does it vary by size (which I assume
is in bits?)? Are there alignment constraints?
These system calls seemed to be type-polymorphic still, which is
problematic for defining a really nice C interface. I would really like
to have a strongly typed interface for this, with a nice struct futex
wrapper type (even if it means that we need four of them).
Will all architectures support all sizes? If not, how do we probe which
size/flags combinations are supported?
> For NUMA I propose that when NUMA_FLAG is set, uaddr-4 will be 'int
> node_id', with the following semantics:
>
> - on WAIT, node_id is read and when 0 <= node_id <= nr_nodes, is
> directly used to index into per-node hash-tables. When -1, it is
> replaced by the current node_id and an smp_mb() is issued before we
> load and compare the @uaddr.
>
> - on WAKE/REQUEUE, it is an immediate index.
Does this mean the first waiter determines the NUMA index, and all
future waiters use the same chain even if they are on different nodes?
I think documenting this as a node index would be a mistake. It could
be an arbitrary hint for locating the corresponding kernel data
structures.
> Any invalid value with result in EINVAL.
Using uaddr-4 is slightly tricky with a 64-bit futex value, due to the
need to maintain alignment and avoid padding.
Thanks,
Florian
next prev parent reply other threads:[~2020-03-03 13:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-13 21:45 [PATCH v3 0/4] Implement FUTEX_WAIT_MULTIPLE operation André Almeida
2020-02-13 21:45 ` [PATCH v3 1/4] futex: Implement mechanism to wait on any of several futexes André Almeida
2020-02-28 19:07 ` Peter Zijlstra
2020-02-28 19:49 ` Peter Zijlstra
2020-02-28 21:25 ` Thomas Gleixner
2020-02-29 0:29 ` Pierre-Loup A. Griffais
2020-02-29 10:27 ` Thomas Gleixner
2020-03-03 2:47 ` Pierre-Loup A. Griffais
2020-03-03 12:00 ` 'simple' futex interface [Was: [PATCH v3 1/4] futex: Implement mechanism to wait on any of several futexes] Peter Zijlstra
2020-03-03 13:00 ` Florian Weimer [this message]
2020-03-03 13:21 ` Peter Zijlstra
2020-03-03 13:47 ` Florian Weimer
2020-03-03 15:01 ` Peter Zijlstra
2020-03-05 16:14 ` André Almeida
2020-03-05 16:25 ` Florian Weimer
2020-03-05 18:51 ` Peter Zijlstra
2020-03-06 16:57 ` David Laight
2020-02-13 21:45 ` [PATCH v3 2/4] selftests: futex: Add FUTEX_WAIT_MULTIPLE timeout test André Almeida
2020-02-13 21:45 ` [PATCH v3 3/4] selftests: futex: Add FUTEX_WAIT_MULTIPLE wouldblock test André Almeida
2020-02-13 21:45 ` [PATCH v3 4/4] selftests: futex: Add FUTEX_WAIT_MULTIPLE wake up test André Almeida
2020-02-19 16:27 ` [PATCH v3 0/4] Implement FUTEX_WAIT_MULTIPLE operation shuah
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=87pndth9ur.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=andrealmeid@collabora.com \
--cc=carlos@redhat.com \
--cc=dvhart@infradead.org \
--cc=kernel@collabora.com \
--cc=krisman@collabora.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=malteskarupke@web.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pgriffais@valvesoftware.com \
--cc=rostedt@goodmis.org \
--cc=ryao@gentoo.org \
--cc=shuah@kernel.org \
--cc=steven@liquorix.net \
--cc=steven@valvesoftware.com \
--cc=tglx@linutronix.de \
--cc=z.figura12@gmail.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;
as well as URLs for NNTP newsgroup(s).