Skip to content

RFC Restartable Sequences

Mathieu Desnoyers linux-api linux-kselftest linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest14 patches 41 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14uapi headers: Provide types_32_64.h (v2)include/uapi/linux/types_32_64.h+50 -00 replies
2/14rseq: Introduce restartable sequences system call (v13)MAINTAINERS arch/Kconfig fs/exec.c +10 more+734 -12 replies
3/14arm: Add restartable sequences supportarch/arm/Kconfig arch/arm/kernel/signal.c+8 -05 replies
4/14arm: Wire up restartable sequences system callarch/arm/tools/syscall.tbl+1 -00 replies
5/14x86: Add support for restartable sequences (v2)arch/x86/Kconfig arch/x86/entry/common.c arch/x86/kernel/signal.c+10 -00 replies
6/14x86: Wire up restartable sequence system callarch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_64.tbl+2 -00 replies
7/14powerpc: Add support for restartable sequencesarch/powerpc/Kconfig arch/powerpc/kernel/signal.c+4 -014 replies
8/14powerpc: Wire up restartable sequences system callarch/powerpc/include/asm/systbl.h arch/powerpc/include/asm/unistd.h arch/powerpc/include/uapi/asm/unistd.h+3 -10 replies
9/14selftests: lib.mk: Introduce OVERRIDE_TARGETStools/testing/selftests/lib.mk+4 -00 replies
10/14rseq: selftests: Provide rseq library (v5)tools/testing/selftests/rseq/rseq-arm.h tools/testing/selftests/rseq/rseq-ppc.h tools/testing/selftests/rseq/rseq-skip.h +3 more+2847 -00 replies
11/14rseq: selftests: Provide basic testtools/testing/selftests/rseq/basic_test.c+56 -00 replies
12/14rseq: selftests: Provide basic percpu ops test (v2)tools/testing/selftests/rseq/basic_percpu_ops_test.c+313 -00 replies
13/14rseq: selftests: Provide parametrized tests (v2)tools/testing/selftests/rseq/param_test.c+1260 -00 replies
14/14rseq: selftests: Provide Makefile, scripts, gitignore (v2)MAINTAINERS tools/testing/selftests/Makefile tools/testing/selftests/rseq/.gitignore +2 more+159 -00 replies

Reviews trailers per patch

4 of 14 patches have a Reviewed-by or Acked-by.

PatchThomas GleixnerShuah KhanPeter Zijlstra (Intel)
1/14
2/14A-b
3/14
4/14
5/14R-b
6/14R-b
7/14
8/14
9/14A-b
10/14
11/14
12/14
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [RFC PATCH for 4.18 00/14] Restartable Sequences

Hi,

Here is an updated RFC round of the Restartable Sequences patchset based on kernel 4.17-rc3. Based on feedback from Linus, I'm introducing only the rseq system call, keeping the rest for later.

This already enables speeding up the Facebook jemalloc and arm64 PMC read from user-space use-cases, as well as speedup of use-cases relying on getting the current cpu number from user-space. We'll have to wait until a more complete solution is introduced before the LTTng-UST tracer can replace its ring buffer atomic instructions with rseq though. But let's proceed one step at a time.

The main change introduced by the removal of cpu_opv from this series in terms of library use from user-space is that APIs that previously took a CPU number as argument now only act on the current CPU.

So for instance, this turns:

  int cpu = rseq_per_cpu_lock(lock, target_cpu);
  [...]
  rseq_per_cpu_unlock(lock, cpu);

into

  int cpu = rseq_this_cpu_lock(lock);
  [...]
  rseq_per_cpu_unlock(lock, cpu);

and:

  per_cpu_list_push(list, node, target_cpu);
  [...]
  per_cpu_list_pop(list, node, target_cpu);

into

this_cpu_list_push(list, node, &cpu); /* cpu is an output parameter. */ [...]
node = this_cpu_list_pop(list, &cpu); /* cpu is an output parameter. */

Eventually integrating cpu_opv or some alternative will allow passing the cpu number as parameter rather than requiring the algorithm to work on the current CPU.

The second effect of not having the cpu_opv fallback is that line and instruction single-stepping with a debugger transforms rseq critical sections based on retry loops into never-ending loops. Debuggers need to use the __rseq_table section to skip those critical sections in order to correctly behave when single-stepping a thread which uses rseq in a retry loop. However, applications which use an alternative fallback method rather than retrying on rseq fast-path abort won't be affected by this kind of single-stepping issue.

Feedback is welcome!

Thanks,

Mathieu

Boqun Feng (2):
powerpc: Add support for restartable sequences
powerpc: Wire up restartable sequences system call

Mathieu Desnoyers (12):
uapi headers: Provide types_32_64.h (v2)
rseq: Introduce restartable sequences system call (v13)
arm: Add restartable sequences support
arm: Wire up restartable sequences system call
x86: Add support for restartable sequences (v2)
x86: Wire up restartable sequence system call
selftests: lib.mk: Introduce OVERRIDE_TARGETS
rseq: selftests: Provide rseq library (v5)
rseq: selftests: Provide basic test
rseq: selftests: Provide basic percpu ops test (v2)
rseq: selftests: Provide parametrized tests (v2)
rseq: selftests: Provide Makefile, scripts, gitignore (v2)

 MAINTAINERS                                        |   12 +
 arch/Kconfig                                       |    7 +
 arch/arm/Kconfig                                   |    1 +
 arch/arm/kernel/signal.c                           |    7 +
 arch/arm/tools/syscall.tbl                         |    1 +
 arch/powerpc/Kconfig                               |    1 +
 arch/powerpc/include/asm/systbl.h                  |    1 +
 arch/powerpc/include/asm/unistd.h                  |    2 +-
 arch/powerpc/include/uapi/asm/unistd.h             |    1 +
 arch/powerpc/kernel/signal.c                       |    3 +
 arch/x86/Kconfig                                   |    1 +
 arch/x86/entry/common.c                            |    3 +
 arch/x86/entry/syscalls/syscall_32.tbl             |    1 +
 arch/x86/entry/syscalls/syscall_64.tbl             |    1 +
 arch/x86/kernel/signal.c                           |    6 +
 fs/exec.c                                          |    1 +
 include/linux/sched.h                              |  134 +++
 include/linux/syscalls.h                           |    4 +-
 include/trace/events/rseq.h                        |   56 +
 include/uapi/linux/rseq.h                          |  150 +++
 include/uapi/linux/types_32_64.h                   |   67 ++
 init/Kconfig                                       |   23 +
 kernel/Makefile                                    |    1 +
 kernel/fork.c                                      |    2 +
 kernel/rseq.c                                      |  366 ++++++
 kernel/sched/core.c                                |    2 +
 kernel/sys_ni.c                                    |    3 +
 tools/testing/selftests/Makefile                   |    1 +
 tools/testing/selftests/lib.mk                     |    4 +
 tools/testing/selftests/rseq/.gitignore            |    6 +
 tools/testing/selftests/rseq/Makefile              |   29 +
 .../testing/selftests/rseq/basic_percpu_ops_test.c |  312 +++++
 tools/testing/selftests/rseq/basic_test.c          |   55 +
 tools/testing/selftests/rseq/param_test.c          | 1259 ++++++++++++++++++++
 tools/testing/selftests/rseq/rseq-arm.h            |  732 ++++++++++++
 tools/testing/selftests/rseq/rseq-ppc.h            |  688 +++++++++++
 tools/testing/selftests/rseq/rseq-skip.h           |   82 ++
 tools/testing/selftests/rseq/rseq-x86.h            | 1149 ++++++++++++++++++
 tools/testing/selftests/rseq/rseq.c                |  116 ++
 tools/testing/selftests/rseq/rseq.h                |  164 +++
 tools/testing/selftests/rseq/run_param_test.sh     |  120 ++
 41 files changed, 5572 insertions(+), 2 deletions(-)
 create mode 100644 include/trace/events/rseq.h
 create mode 100644 include/uapi/linux/rseq.h
 create mode 100644 include/uapi/linux/types_32_64.h
 create mode 100644 kernel/rseq.c
 create mode 100644 tools/testing/selftests/rseq/.gitignore
 create mode 100644 tools/testing/selftests/rseq/Makefile
 create mode 100644 tools/testing/selftests/rseq/basic_percpu_ops_test.c
 create mode 100644 tools/testing/selftests/rseq/basic_test.c
 create mode 100644 tools/testing/selftests/rseq/param_test.c
 create mode 100644 tools/testing/selftests/rseq/rseq-arm.h
 create mode 100644 tools/testing/selftests/rseq/rseq-ppc.h
 create mode 100644 tools/testing/selftests/rseq/rseq-skip.h
 create mode 100644 tools/testing/selftests/rseq/rseq-x86.h
 create mode 100644 tools/testing/selftests/rseq/rseq.c
 create mode 100644 tools/testing/selftests/rseq/rseq.h
 create mode 100755 tools/testing/selftests/rseq/run_param_test.sh
Signature · 1 line
2.11.0