Linux userland API discussions
 help / color / mirror / Atom feed
* [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls
@ 2026-12-04 16:15 André Almeida
  2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: André Almeida @ 2026-12-04 16:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Arnd Bergmann, Sebastian Andrzej Siewior, Waiman Long,
	Ryan Houdek, Florian Weimer, Thomas Gleixner
  Cc: linux-kernel, linux-kselftest, linux-api, kernel-dev, libc-coord,
	André Almeida

This patchset creates two new syscalls {set,get}_robust_list2(), that allows for
setting multiple lists per task and using 32-bit lists on 64-bit kernels.

 * Use case

The use-case for the new syscalls is detailed in the last patch version:

  https://lore.kernel.org/lkml/20250626-tonyk-robust_futex-v5-0-179194dbde8f@igalia.com

 * The syscall interface

Userspace have access to two sysctl to get the list limits:
 - futex.robust_list2_list_limit: the number of robust_list heads per task
 - futex.robust_list2_elements_per_list: for every list, how many elements can
 it handle

After that, userspace can set a robust list like:

  idx = set_robust_list2(head, 0, FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY);

On success, idx gives the index on the robust lists array that where head was
set.

Getting the list head for this index:

  get_robust_list2(0, &head, idx, 0);

To clean such index later, userspace can use:

  set_robust_list2(NULL, idx, 0);

The kernel guarantees that an index returned by NEW_ENTRY is an empty element.
Userspace is the responsible for not messing up with the list.

The commit message that introduces each syscall has the detailed information
about the interface.

 * Testing

I expanded the current robust list selftest to use the new interface,
and also ported the original syscall to use the new syscall internals,
and everything survived the tests. Tested on both x86 and arm64.

Also tested with glibc's tests nptl/tst-robust* and nptl/tst-mutex*.

 * Changelog

Changes from v8:
- Simplified the syscall interface. No more CREATE/MODIFY flags.
- The code itself got much simpler as well, without the switch case multiplexing
- User can modify any index at any giving time. To create, a flag
  FUTEX_ROBUST_LIST2_FLAG_NEW_ENTRY returns an unused index
- Reordered the preparatory patches
- Link to v8: https://patch.msgid.link/20261115-tonyk-robust_futex-v8-0-a4fe47333a28@igalia.com

Changes from v7:
- Expanded the selftest for more corner cases and error handling
- Fix a lot of Sashiko findings, including:
- Refactor handling of 32-bit lists in get_robust_list2 
- Fix legacy 32-bit list creation overwritting 64-bit list
- Fix 32-bit list never getting cleared
- Fix corrupting error code
- Fix logic for modifying list elements
- Link to v7: https://patch.msgid.link/20260925-tonyk-robust_futex-v7-0-d1095991152c@igalia.com

Changes from v6:
 - Interface now uses CREATE/MODIFY semantics instead of SET. This allows to
 both libc and app to use the lists without conflicts.
 - Rebased on top of mainline, including the new VDSO changes
 - v6: https://lore.kernel.org/r/20251122-tonyk-robust_futex-v6-0-05fea005a0fd@igalia.com

Changes from v5:
 - Complete interface rewrite, there are so many changes but the main
   ones are the following points
 - Array of robust lists now has a static size, allocated once during the
   first usage of the list
 - Now that the list of robust lists have a fixed size, I removed the
   logic of having a command for creating a new index on the list. To
   simplify things for everyone, userspace just need to call
   set_robust_list2(head, 32-bit/64-bit type, index).
 - Created get_robust_list2()
 - The new code can be better integrated with the original interface
 - v5: https://lore.kernel.org/r/20250626-tonyk-robust_futex-v5-0-179194dbde8f@igalia.com

Feedback is very welcomed!

---
---
André Almeida (14):
      futex: Use explicit sizes for compat_robust_list structs
      futex: Make exit_robust_list32() unconditionally available for 64-bit kernels
      futex: Give a specific head pointer to exit_robust_list()
      futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists
      futex: Create exit_robust_lists() for multi-robust list
      futex: Use the multi-robust list infrastructure for current syscalls
      futex: Expose robust_list2 limits via sysctl
      futex: Create syscall set_robust_list2()
      futex: Make futex_task_robust_list() get list by index
      futex: Create get_robust_list2() syscall
      futex: Wire up set_robust_list2 syscall
      futex: Wire up get_robust_list2 syscall
      selftests/futex: Expand for set_robust_list2()
      selftests/futex: Expand for get_robust_list2()

 arch/alpha/kernel/syscalls/syscall.tbl             |   2 +
 arch/arm/tools/syscall.tbl                         |   2 +
 arch/m68k/kernel/syscalls/syscall.tbl              |   2 +
 arch/microblaze/kernel/syscalls/syscall.tbl        |   2 +
 arch/mips/kernel/syscalls/syscall_n32.tbl          |   2 +
 arch/mips/kernel/syscalls/syscall_n64.tbl          |   2 +
 arch/mips/kernel/syscalls/syscall_o32.tbl          |   2 +
 arch/parisc/kernel/syscalls/syscall.tbl            |   2 +
 arch/powerpc/kernel/syscalls/syscall.tbl           |   2 +
 arch/s390/kernel/syscalls/syscall.tbl              |   2 +
 arch/sh/kernel/syscalls/syscall.tbl                |   2 +
 arch/sparc/kernel/syscalls/syscall.tbl             |   2 +
 arch/x86/entry/syscalls/syscall_32.tbl             |   2 +
 arch/x86/entry/syscalls/syscall_64.tbl             |   2 +
 arch/xtensa/kernel/syscalls/syscall.tbl            |   2 +
 include/linux/compat.h                             |  13 +-
 include/linux/futex.h                              |   1 +
 include/linux/futex_types.h                        |   9 +-
 include/uapi/asm-generic/unistd.h                  |   7 +-
 include/uapi/linux/futex.h                         |  17 +
 kernel/futex/core.c                                | 193 +++++--
 kernel/futex/futex.h                               |  16 +
 kernel/futex/syscalls.c                            |  91 +++-
 scripts/syscall.tbl                                |   2 +
 .../selftests/futex/functional/robust_list.c       | 594 +++++++++++++++++++--
 25 files changed, 856 insertions(+), 117 deletions(-)
---
base-commit: 39cc4e512ebcd2a6d106d710285040a4e43c2dd9
change-id: 20250225-tonyk-robust_futex-60adeedac695

Best regards,
--  
André Almeida <andrealmeid@igalia.com>


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

end of thread, other threads:[~2026-12-05  9:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 16:15 [PATCH v9 00/14] futex: Create {set,get}_robust_list2() syscalls André Almeida
2026-12-04 16:15 ` [PATCH v9 01/14] futex: Use explicit sizes for compat_robust_list structs André Almeida
2026-12-04 16:15 ` [PATCH v9 02/14] futex: Make exit_robust_list32() unconditionally available for 64-bit kernels André Almeida
2026-12-04 16:15 ` [PATCH v9 03/14] futex: Give a specific head pointer to exit_robust_list() André Almeida
2026-12-04 16:15 ` [PATCH v9 04/14] futex: Introduce futex_get_robust_lists() and futex_sched_data::robust_lists André Almeida
2026-12-04 16:15 ` [PATCH v9 05/14] futex: Create exit_robust_lists() for multi-robust list André Almeida
2026-12-05  9:55   ` kernel test robot
2026-12-04 16:15 ` [PATCH v9 06/14] futex: Use the multi-robust list infrastructure for current syscalls André Almeida
2026-12-04 16:15 ` [PATCH v9 07/14] futex: Expose robust_list2 limits via sysctl André Almeida
2026-12-04 16:15 ` [PATCH v9 08/14] futex: Create syscall set_robust_list2() André Almeida
2026-12-04 16:15 ` [PATCH v9 09/14] futex: Make futex_task_robust_list() get list by index André Almeida
2026-12-04 16:15 ` [PATCH v9 10/14] futex: Create get_robust_list2() syscall André Almeida
2026-12-04 16:15 ` [PATCH v9 11/14] futex: Wire up set_robust_list2 syscall André Almeida
2026-12-05  9:55   ` kernel test robot
2026-12-05  9:55   ` kernel test robot
2026-12-04 16:15 ` [PATCH v9 12/14] futex: Wire up get_robust_list2 syscall André Almeida
2026-12-04 16:15 ` [PATCH v9 13/14] selftests/futex: Expand for set_robust_list2() André Almeida
2026-12-04 16:15 ` [PATCH v9 14/14] selftests/futex: Expand for get_robust_list2() André Almeida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox