futex: splitup and waitv syscall
Status from this message: The following commit has been merged into the locking/core branch of tip:
Get series with b4
b4 am [email protected]Versions newest first
Changelog from the cover letter
v1: https://lore.kernel.org/lkml/[email protected]/
- Added a clockid argument in sys_futex_waitv()
- This required some changes in the timeout init
- Added test for wouldblock
- Added documentation file
- Fixed error path order for futex_wait_multiple()
- Return error if FUTEX_32 is not set for a waiter
- Extended futex_waitv() selftest to cover error paths like this
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/22 | futex: Move to kernel/futex/MAINTAINERS kernel/ kernel/ +1 more | +6 | 2 replies | |
| 2/22 | futex: Split out syscallsinclude/ kernel/ kernel/ +3 more | +455 | 0 replies | |
| 3/22 | futex: Rename {,__}{,un}queue_me()kernel/ | +23 | 0 replies | |
| 4/22 | futex: Rename futex_wait_queue_me()kernel/ | +5 | 0 replies | |
| 5/22 | futex: Rename: queue_{,un}lock()kernel/ | +13 | 0 replies | |
| 6/22 | futex: Rename __unqueue_futex()kernel/ | +7 | 0 replies | |
| 7/22 | futex: Rename hash_futex()kernel/ | +11 | 0 replies | |
| 8/22 | futex: Rename: {get,cmpxchg}_futex_value_locked()kernel/ | +15 | 0 replies | |
| 9/22 | futex: Split out PI futexkernel/ kernel/ kernel/ +1 more | +1452 | 0 replies | |
| 10/22 | futex: Rename: hb_waiter_{inc,dec,pending}()kernel/ | +17 | 0 replies | |
| 11/22 | futex: Rename: match_futex()kernel/ | +12 | 0 replies | |
| 12/22 | futex: Rename mark_wake_futex()kernel/ | +5 | 0 replies | |
| 13/22 | futex: Split out requeuekernel/ kernel/ kernel/ +1 more | +979 | 2 replies | |
| 14/22 | futex: Split out wait/wakekernel/ kernel/ kernel/ +1 more | +543 | 0 replies | |
| 15/22 | futex: Simplify double_lock_hb()kernel/ | +6 | 0 replies | |
| 16/22 | futex: Implement sys_futex_waitv()MAINTAINERS include/ include/ +5 more | +369 | 3 replies | |
| 17/22 | futex,x86: Wire up sys_futex_waitv()arch/ arch/ | +2 | 0 replies | |
| 18/22 | futex,arm: Wire up sys_futex_waitv()arch/ arch/ arch/ | +4 | 0 replies | |
| 19/22 | selftests: futex: Add sys_futex_waitv() testtools/ tools/ tools/ +2 more | +265 | 0 replies | |
| 20/22 | selftests: futex: Test sys_futex_waitv() timeouttools/ | +20 | 4 replies | |
| 21/22 | selftests: futex: Test sys_futex_waitv() wouldblocktools/ | +37 | 0 replies | |
| 22/22 | futex2: Documentation: Document sys_futex_waitv() uAPIDocumentation/ Documentation/ | +87 | 0 replies |
Reviews trailers per patch
15 of 22 patches have a Reviewed-by or Acked-by.
| Patch | André Almeida |
|---|---|
| 1/22 | R-b |
| 2/22 | R-b |
| 3/22 | R-b |
| 4/22 | R-b |
| 5/22 | R-b |
| 6/22 | R-b |
| 7/22 | R-b |
| 8/22 | R-b |
| 9/22 | R-b |
| 10/22 | R-b |
| 11/22 | R-b |
| 12/22 | R-b |
| 13/22 | R-b |
| 14/22 | R-b |
| 15/22 | R-b |
| 16/22 | |
| 17/22 | |
| 18/22 | |
| 19/22 | |
| 20/22 | |
| 21/22 | |
| 22/22 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 00/22] futex: splitup and waitv syscall
This v2 is a followup of Peter's patchset that addresses feedback from the Linux Plumbers Conference session about new futex syscalls.
Changelog:
v1: https://lore.kernel.org/lkml/[email protected]/
- Added a clockid argument in sys_futex_waitv()
- This required some changes in the timeout init
- Added test for wouldblock
- Added documentation file
- Fixed error path order for futex_wait_multiple()
- Return error if FUTEX_32 is not set for a waiter
- Extended futex_waitv() selftest to cover error paths like this
Original cover letter for this syscall (extracted from
https://lore.kernel.org/lkml/[email protected]/):
This patchset introduce the futex_waitv syscall, that enables userspace to wait in an array of futexes and wake on any.
* Use case
The use case of this syscall is to allow low level locking libraries to wait for multiple locks at the same time. This is specially useful for emulating Windows' WaitForMultipleObjects. A futex_waitv()-based solution has been used for some time at Proton's Wine (a compatibility layer to run Windows games on Linux). Compared to a solution that uses eventfd(), futex was able to reduce CPU utilization for games, and even increase frames per second for some games. This happens because eventfd doesn't scale very well for a huge number of read, write and poll calls compared to futex. Native game engines will benefit of this as well, given that this wait pattern is common for games.
* The interface
This is how the interface looks like:
futex_waitv(struct futex_waitv *waiters, unsigned int nr_futexes,
unsigned int flags, struct timespec *timo, clockid_t clockid)
struct futex_waitv {
__u64 val;
__u64 uaddr;
__u32 flags;
__u32 __reserved;
};struct futex_waitv uses explicit padding, so we can use it in all architectures. The __reserved is used for the padding and should always be 0, but it may be repurposed in the future for some extension. If userspace has 32-bit pointers, it should do a explicit cast to make sure the upper bits are zeroed. uintptr_t does the tricky and it works for 32/64-bit pointers. The documentation patch provides more detailed information about the interface.
André Almeida (7):
futex: Implement sys_futex_waitv() futex,x86: Wire up sys_futex_waitv() futex,arm: Wire up sys_futex_waitv()
selftests: futex: Add sys_futex_waitv() test
selftests: futex: Test sys_futex_waitv() timeout
selftests: futex: Test sys_futex_waitv() wouldblock
futex2: Documentation: Document futex_waitv() uAPI
Peter Zijlstra (15):
futex: Move to kernel/futex/
futex: Split out syscalls
futex: Rename {,__}{,un}queue_me()
futex: Rename futex_wait_queue_me()
futex: Rename: queue_{,un}lock()
futex: Rename __unqueue_futex()
futex: Rename hash_futex()
futex: Rename: {get,cmpxchg}_futex_value_locked()
futex: Split out PI futex
futex: Rename: hb_waiter_{inc,dec,pending}()
futex: Rename: match_futex()
futex: Rename mark_wake_futex()
futex: Split out requeue
futex: Split out wait/wake
futex: Simplify double_lock_hb()
Documentation/userspace-api/futex2.rst | 81 + Documentation/userspace-api/index.rst | 1 + MAINTAINERS | 3 +- arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + include/linux/syscalls.h | 6 + include/uapi/asm-generic/unistd.h | 5 +- include/uapi/linux/futex.h | 25 + kernel/Makefile | 2 +- kernel/futex.c | 4272 ----------------- kernel/futex/Makefile | 3 + kernel/futex/core.c | 1176 +++++ kernel/futex/futex.h | 295 ++ kernel/futex/pi.c | 1233 +++++ kernel/futex/requeue.c | 897 ++++ kernel/futex/syscalls.c | 387 ++ kernel/futex/waitwake.c | 708 +++ kernel/sys_ni.c | 3 + .../selftests/futex/functional/.gitignore | 1 + .../selftests/futex/functional/Makefile | 3 +- .../futex/functional/futex_wait_timeout.c | 21 +- .../futex/functional/futex_wait_wouldblock.c | 41 +- .../selftests/futex/functional/futex_waitv.c | 158 + .../testing/selftests/futex/functional/run.sh | 3 + .../selftests/futex/include/futex2test.h | 31 + 28 files changed, 5080 insertions(+), 4282 deletions(-) create mode 100644 Documentation/userspace-api/futex2.rst delete mode 100644 kernel/futex.c create mode 100644 kernel/futex/Makefile create mode 100644 kernel/futex/core.c create mode 100644 kernel/futex/futex.h create mode 100644 kernel/futex/pi.c create mode 100644 kernel/futex/requeue.c create mode 100644 kernel/futex/syscalls.c create mode 100644 kernel/futex/waitwake.c create mode 100644 tools/testing/selftests/futex/functional/futex_waitv.c create mode 100644 tools/testing/selftests/futex/include/futex2test.h
--
2.33.0