[PATCH v6 0/9] futex: Create {set,get}_robust_list2() syscalls

André Almeida posted 9 patches 1 week, 2 days ago
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                              |  30 +-
include/linux/sched.h                              |   6 +-
include/uapi/asm-generic/unistd.h                  |   7 +-
include/uapi/linux/futex.h                         |  26 ++
kernel/futex/core.c                                | 140 ++++--
kernel/futex/syscalls.c                            | 134 +++++-
kernel/sys_ni.c                                    |   2 +
scripts/syscall.tbl                                |   1 +
.../selftests/futex/functional/robust_list.c       | 504 +++++++++++++++++++--
25 files changed, 788 insertions(+), 105 deletions(-)
[PATCH v6 0/9] futex: Create {set,get}_robust_list2() syscalls
Posted by André Almeida 1 week, 2 days ago
Hello,

This version is a complete rewrite of the syscall (thanks Thomas for the
suggestions!). 

 * 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

Documented at patches 3/9 "futex: Create set_robust_list2() syscall" and
4/9 "futex: Create get_robust_list2() syscall".

 * 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.

 * Changelog

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 (9):
      futex: Use explicit sizes for compat_robust_list structs
      futex: Make exit_robust_list32() unconditionally available for 64-bit kernels
      futex: Create set_robust_list2() syscall
      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()
      futex: Use new robust list API internally

 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                              |  30 +-
 include/linux/sched.h                              |   6 +-
 include/uapi/asm-generic/unistd.h                  |   7 +-
 include/uapi/linux/futex.h                         |  26 ++
 kernel/futex/core.c                                | 140 ++++--
 kernel/futex/syscalls.c                            | 134 +++++-
 kernel/sys_ni.c                                    |   2 +
 scripts/syscall.tbl                                |   1 +
 .../selftests/futex/functional/robust_list.c       | 504 +++++++++++++++++++--
 25 files changed, 788 insertions(+), 105 deletions(-)
---
base-commit: c42ba5a87bdccbca11403b7ca8bad1a57b833732
change-id: 20250225-tonyk-robust_futex-60adeedac695

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

Re: [PATCH v6 0/9] futex: Create {set,get}_robust_list2() syscalls
Posted by André Almeida 1 week, 2 days ago
Em 22/11/2025 02:50, André Almeida escreveu:
> Hello,
> 
> This version is a complete rewrite of the syscall (thanks Thomas for the
> suggestions!).
> 
>   * 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
> 
> Documented at patches 3/9 "futex: Create set_robust_list2() syscall" and
> 4/9 "futex: Create get_robust_list2() syscall".
> 
>   * 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.
> 
>   * Changelog
> 
> 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).

Actually, this won't work well. The application that calls 
set_robust_list2() may be using glibc, that will also want to call 
set_robust_list2(), and there's no way to know which lists are being by 
each library. I will re-add the create/modify logic for the next version.