Merge tag 'tif-task_work.arch-2020-12-14' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 20:33:35 +0000 (12:33 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 20:33:35 +0000 (12:33 -0800)
Pull TIF_NOTIFY_SIGNAL updates from Jens Axboe:
 "This sits on top of of the core entry/exit and x86 entry branch from
  the tip tree, which contains the generic and x86 parts of this work.

  Here we convert the rest of the archs to support TIF_NOTIFY_SIGNAL.

  With that done, we can get rid of JOBCTL_TASK_WORK from task_work and
  signal.c, and also remove a deadlock work-around in io_uring around
  knowing that signal based task_work waking is invoked with the sighand
  wait queue head lock.

  The motivation for this work is to decouple signal notify based
  task_work, of which io_uring is a heavy user of, from sighand. The
  sighand lock becomes a huge contention point, particularly for
  threaded workloads where it's shared between threads. Even outside of
  threaded applications it's slower than it needs to be.

  Roman Gershman <romger@amazon.com> reported that his networked
  workload dropped from 1.6M QPS at 80% CPU to 1.0M QPS at 100% CPU
  after io_uring was changed to use TIF_NOTIFY_SIGNAL. The time was all
  spent hammering on the sighand lock, showing 57% of the CPU time there
  [1].

  There are further cleanups possible on top of this. One example is
  TIF_PATCH_PENDING, where a patch already exists to use
  TIF_NOTIFY_SIGNAL instead. Hopefully this will also lead to more
  consolidation, but the work stands on its own as well"

[1] https://github.com/axboe/liburing/issues/215

* tag 'tif-task_work.arch-2020-12-14' of git://git.kernel.dk/linux-block: (28 commits)
  io_uring: remove 'twa_signal_ok' deadlock work-around
  kernel: remove checking for TIF_NOTIFY_SIGNAL
  signal: kill JOBCTL_TASK_WORK
  io_uring: JOBCTL_TASK_WORK is no longer used by task_work
  task_work: remove legacy TWA_SIGNAL path
  sparc: add support for TIF_NOTIFY_SIGNAL
  riscv: add support for TIF_NOTIFY_SIGNAL
  nds32: add support for TIF_NOTIFY_SIGNAL
  ia64: add support for TIF_NOTIFY_SIGNAL
  h8300: add support for TIF_NOTIFY_SIGNAL
  c6x: add support for TIF_NOTIFY_SIGNAL
  alpha: add support for TIF_NOTIFY_SIGNAL
  xtensa: add support for TIF_NOTIFY_SIGNAL
  arm: add support for TIF_NOTIFY_SIGNAL
  microblaze: add support for TIF_NOTIFY_SIGNAL
  hexagon: add support for TIF_NOTIFY_SIGNAL
  csky: add support for TIF_NOTIFY_SIGNAL
  openrisc: add support for TIF_NOTIFY_SIGNAL
  sh: add support for TIF_NOTIFY_SIGNAL
  um: add support for TIF_NOTIFY_SIGNAL
  ...

12 files changed:
1  2 
arch/arm64/include/asm/thread_info.h
arch/arm64/kernel/signal.c
arch/hexagon/kernel/process.c
arch/ia64/kernel/process.c
arch/s390/include/asm/thread_info.h
arch/s390/kernel/entry.S
arch/um/kernel/process.c
fs/io_uring.c
include/linux/entry-common.h
include/linux/sched/signal.h
include/linux/tracehook.h
kernel/signal.c

index 015beafe58f539849554651e013a93e89b25d152,cdcf307764aada48973ed47d591b06c6a0bb621d..b24056a0b02b6482ba8caf9d726bad59fd265ee4
@@@ -63,7 -66,9 +63,8 @@@ void arch_release_task_struct(struct ta
  #define TIF_NOTIFY_RESUME     2       /* callback before returning to user */
  #define TIF_FOREIGN_FPSTATE   3       /* CPU's FP state is not current's */
  #define TIF_UPROBE            4       /* uprobe breakpoint or singlestep */
 -#define TIF_FSCHECK           5       /* Check FS is USER_DS on return */
 -#define TIF_MTE_ASYNC_FAULT   6       /* MTE Asynchronous Tag Check Fault */
 +#define TIF_MTE_ASYNC_FAULT   5       /* MTE Asynchronous Tag Check Fault */
+ #define TIF_NOTIFY_SIGNAL     7       /* signal notifications exist */
  #define TIF_SYSCALL_TRACE     8       /* syscall trace active */
  #define TIF_SYSCALL_AUDIT     9       /* syscall auditing */
  #define TIF_SYSCALL_TRACEPOINT        10      /* syscall tracepoint for ftrace */
  
  #define _TIF_WORK_MASK                (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
                                 _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
-                                _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT)
 -                               _TIF_UPROBE | _TIF_FSCHECK | _TIF_MTE_ASYNC_FAULT | \
++                               _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
+                                _TIF_NOTIFY_SIGNAL)
  
  #define _TIF_SYSCALL_WORK     (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
                                 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
Simple merge
Simple merge
Simple merge
Simple merge
index 8bb9ebb71c4b2b2f4a1d8dbfc681d8a757d0180f,19a89f2922903d1d6d461358da7a74e189217a81..1f4659203f8c50d6233e4de958087772924cd65f
@@@ -52,10 -52,11 +52,11 @@@ STACK_SIZE  = 1 << STACK_SHIF
  STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
  
  _TIF_WORK     = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
-                  _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING)
+                  _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING | \
+                  _TIF_NOTIFY_SIGNAL)
  _TIF_TRACE    = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
                   _TIF_SYSCALL_TRACEPOINT)
 -_CIF_WORK     = (_CIF_ASCE_PRIMARY | _CIF_ASCE_SECONDARY | _CIF_FPU)
 +_CIF_WORK     = (_CIF_FPU)
  _PIF_WORK     = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
  
  _LPP_OFFSET   = __LC_LPP
@@@ -486,10 -464,12 +487,10 @@@ ENTRY(system_call
  #endif
        TSTMSK  __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
        jo      .Lsysc_syscall_restart
-       TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
-       j     .Lsysc_sigpending
+       TSTMSK  __TI_flags(%r12),(_TIF_SIGPENDING|_TIF_NOTIFY_SIGNAL)
+       jnz     .Lsysc_sigpending
        TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
        jo      .Lsysc_notify_resume
 -      TSTMSK  __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
 -      jnz     .Lsysc_asce
        j       .Lsysc_return
  
  #
Simple merge
diff --cc fs/io_uring.c
Simple merge
index 7c581a4c379750804f958d864f0ce65adf654b0c,abec3a5ae7997b9290715b55968e01bb8ccec557..ca86a00abe862112b77b3007ba33811ee1bd2698
  # define _TIF_UPROBE                  (0)
  #endif
  
- #ifndef _TIF_NOTIFY_SIGNAL
- # define _TIF_NOTIFY_SIGNAL           (0)
- #endif
  /*
 - * TIF flags handled in syscall_enter_from_user_mode()
 + * SYSCALL_WORK flags handled in syscall_enter_from_user_mode()
   */
 -#ifndef ARCH_SYSCALL_ENTER_WORK
 -# define ARCH_SYSCALL_ENTER_WORK      (0)
 +#ifndef ARCH_SYSCALL_WORK_ENTER
 +# define ARCH_SYSCALL_WORK_ENTER      (0)
  #endif
  
 -#define SYSCALL_ENTER_WORK                                            \
 -      (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP |       \
 -       _TIF_SYSCALL_TRACEPOINT | _TIF_SYSCALL_EMU |                   \
 -       ARCH_SYSCALL_ENTER_WORK)
 -
  /*
 - * TIF flags handled in syscall_exit_to_user_mode()
 + * SYSCALL_WORK flags handled in syscall_exit_to_user_mode()
   */
 -#ifndef ARCH_SYSCALL_EXIT_WORK
 -# define ARCH_SYSCALL_EXIT_WORK               (0)
 +#ifndef ARCH_SYSCALL_WORK_EXIT
 +# define ARCH_SYSCALL_WORK_EXIT               (0)
  #endif
  
 -#define SYSCALL_EXIT_WORK                                             \
 -      (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT |                      \
 -       _TIF_SYSCALL_TRACEPOINT | ARCH_SYSCALL_EXIT_WORK)
 +#define SYSCALL_WORK_ENTER    (SYSCALL_WORK_SECCOMP |                 \
 +                               SYSCALL_WORK_SYSCALL_TRACEPOINT |      \
 +                               SYSCALL_WORK_SYSCALL_TRACE |           \
 +                               SYSCALL_WORK_SYSCALL_EMU |             \
 +                               SYSCALL_WORK_SYSCALL_AUDIT |           \
 +                               SYSCALL_WORK_SYSCALL_USER_DISPATCH |   \
 +                               ARCH_SYSCALL_WORK_ENTER)
 +#define SYSCALL_WORK_EXIT     (SYSCALL_WORK_SYSCALL_TRACEPOINT |      \
 +                               SYSCALL_WORK_SYSCALL_TRACE |           \
 +                               SYSCALL_WORK_SYSCALL_AUDIT |           \
 +                               SYSCALL_WORK_SYSCALL_USER_DISPATCH |   \
 +                               ARCH_SYSCALL_WORK_EXIT)
  
  /*
   * TIF flags handled in exit_to_user_mode_loop()
Simple merge
Simple merge
diff --cc kernel/signal.c
Simple merge