Skip to content

remove in-kernel syscall invocations (part 1)

Dominik Brodowski linux-mm linux-s390 linux-um lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest36 patches 39 repliesIn review
  2. v1 RFC35 patches 17 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/36syscalls: define goal to not call sys_xyzzy() from within the kernelDocumentation/process/adding-syscalls.rst include/linux/syscalls.h+7 -140 replies
2/36kernel: use kernel_wait4() instead of sys_wait4()kernel/exit.c kernel/pid_namespace.c kernel/umh.c+5 -52 replies
3/36mm: use do_futex() instead of sys_futex() in mm_release()include/linux/futex.h kernel/fork.c+12 -55 replies
4/36kernel: add do_getpgid() helper; remove internal call to sys_getpgid()kernel/sys.c+7 -20 replies
5/36fs: add do_readlinkat() helper; remove internal call to sys_readlinkat()fs/stat.c+9 -30 replies
6/36fs: add do_pipe2() helper; remove internal call to sys_pipe2()fs/pipe.c+7 -20 replies
7/36fs: add do_renameat2() helper; remove internal call to sys_renameat2()fs/namei.c+10 -40 replies
8/36fs: add do_futimesat() helper; remove internal call to sys_futimesat()fs/utimes.c+10 -30 replies
9/36syscalls: add do_epoll_*() helpers; remove internal calls to sys_epoll_*()fs/eventpoll.c+17 -60 replies
10/36fs: add do_signalfd4() helper; remove internal calls to sys_signalfd4()fs/signalfd.c+10 -40 replies
11/36fs: add do_eventfd() helper; remove internal call to sys_eventfd()fs/eventfd.c+7 -20 replies
12/36kernel: open-code sys_rt_sigpending() in sys_sigpending()include/linux/syscalls.h kernel/signal.c+13 -40 replies
13/36x86/ioport: add ksys_ioperm() helper; remove in-kernel calls to sys_ioperm()arch/x86/include/asm/syscalls.h arch/x86/kernel/ioport.c drivers/tty/vt/vt_ioctl.c+10 -45 replies
14/36fs: add ksys_mount() helper; remove in-kernel calls to sys_mount()drivers/base/devtmpfs.c fs/namespace.c include/linux/syscalls.h +2 more+19 -94 replies
15/36fs: add ksys_umount() helper; remove in-kernel call to sys_umount()fs/namespace.c include/linux/syscalls.h init/do_mounts_initrd.c+9 -32 replies
16/36fs: add ksys_dup{,3}() helper; remove in-kernel calls to sys_dup{,3}()fs/file.c include/linux/syscalls.h init/do_mounts_initrd.c +1 more+18 -72 replies
17/36fs: add ksys_chroot() helper; remove-in kernel calls to sys_chroot()drivers/base/devtmpfs.c fs/open.c include/linux/syscalls.h +2 more+11 -53 replies
18/36fs: add ksys_write() helper; remove in-kernel calls to sys_write()arch/s390/kernel/compat_linux.c fs/read_write.c include/linux/syscalls.h +2 more+12 -62 replies
19/36kernel: add ksys_unshare() helper; remove in-kernel calls to sys_unshare()drivers/base/devtmpfs.c include/linux/syscalls.h init/do_mounts_initrd.c +1 more+9 -30 replies
20/36mm: add ksys_fadvise64_64() helper; remove in-kernel call to sys_fadvise64_64()arch/arm/kernel/sys_arm.c arch/mips/kernel/linux32.c arch/parisc/kernel/sys_parisc.c +9 more+43 -270 replies
21/36mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff()arch/alpha/kernel/osf_sys.c arch/arm64/kernel/sys.c arch/ia64/kernel/sys_ia64.c +18 more+60 -411 reply
22/36fs: add ksys_chdir() helper; remove in-kernel calls to sys_chdir()drivers/base/devtmpfs.c fs/open.c include/linux/syscalls.h +2 more+13 -70 replies
23/36fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscallarch/mips/kernel/linux32.c arch/parisc/kernel/sys_parisc.c arch/powerpc/kernel/sys_ppc32.c +5 more+19 -110 replies
24/36fs: add ksys_unlink() wrapper; remove in-kernel calls to sys_unlink()include/linux/syscalls.h init/do_mounts.h init/do_mounts_initrd.c +2 more+17 -62 replies
25/36hostfs: rename do_rmdir() to hostfs_do_rmdir()fs/hostfs/hostfs.h fs/hostfs/hostfs_kern.c fs/hostfs/hostfs_user.c+3 -30 replies
26/36fs: add ksys_rmdir() wrapper; remove in-kernel calls to sys_rmdir()fs/internal.h fs/namei.c include/linux/syscalls.h +1 more+11 -30 replies
27/36fs: add do_mkdirat() helper and ksys_mkdir() wrapper; remove in-kernel calls to syscallfs/internal.h fs/namei.c include/linux/syscalls.h +3 more+19 -60 replies
28/36fs: add do_symlinkat() helper and ksys_symlink() wrapper; remove in-kernel calls to syscallfs/internal.h fs/namei.c include/linux/syscalls.h +1 more+21 -40 replies
29/36fs: add do_mknodat() helper and ksys_mknod() wrapper; remove in-kernel calls to syscallfs/internal.h fs/namei.c include/linux/syscalls.h +3 more+23 -60 replies
30/36fs: add do_linkat() helper and ksys_link() wrapper; remove in-kernel calls to syscallfs/internal.h fs/namei.c include/linux/syscalls.h +1 more+21 -42 replies
31/36fs: add ksys_fchmod() and do_fchmodat() helpers and ksys_chmod() wrapper; remove in-kernel calls to syscallfs/internal.h fs/open.c include/linux/syscalls.h +1 more+27 -60 replies
32/36fs: add do_faccessat() helper and ksys_access() wrapper; remove in-kernel calls to syscallfs/internal.h fs/open.c include/linux/syscalls.h +1 more+17 -30 replies
33/36fs: add ksys_ftruncate() wrapper; remove in-kernel calls to sys_ftruncate()arch/mips/kernel/linux32.c arch/parisc/kernel/sys_parisc.c arch/powerpc/kernel/sys_ppc32.c +7 more+17 -90 replies
34/36fs: add do_fchownat(), ksys_fchown() helpers and ksys_{,l}chown() wrappersarch/s390/kernel/compat_linux.c fs/internal.h fs/open.c +3 more+46 -160 replies
35/36fs: add ksys_close() wrapper; remove in-kernel calls to sys_close()fs/autofs4/dev-ioctl.c fs/binfmt_misc.c fs/file.c +7 more+29 -170 replies
36/36fs: add ksys_open() wrapper; remove in-kernel calls to sys_open()fs/open.c include/linux/syscalls.h init/do_mounts.c +5 more+26 -150 replies

Reviews trailers per patch

3 of 36 patches have a Reviewed-by or Acked-by.

PatchRichard WeinbergerGreg Kroah-HartmanThomas Gleixner
1/36
2/36
3/36R-b
4/36
5/36
6/36
7/36
8/36
9/36
10/36
11/36
12/36
13/36A-b R-b
14/36
15/36
16/36
17/36
18/36
19/36
20/36
21/36
22/36
23/36
24/36
25/36A-b
26/36
27/36
28/36
29/36
30/36
31/36
32/36
33/36
34/36
35/36
36/36

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 v2 thread

Cover letter [PATCH v2 00/36] remove in-kernel syscall invocations (part 1)

Here is a re-spin of the first set of patches which reduce the number of syscall invocations from within the kernel; the RFC may be found at

The rationale for this change is described in patch 1 as follows:

The syscall entry points to the kernel defined by SYSCALL_DEFINEx() and COMPAT_SYSCALL_DEFINEx() should only be called from userspace through kernel entry points, but not from the kernel itself. This will allow cleanups and optimizations to the entry paths *and* to the parts of the kernel code which currently need to pretend to be userspace in order to make use of syscalls.

The whole series can be found at

https://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux.git syscalls-next

and will be submitted for merging for the v4.17-rc1 cycle, probably together with another batch of related patches I hope to send out tomorrow as a RFC.

Changes since the RFC / v1:

- rebase to v4.15-rc5; sys_ioperm already got its SYSCALL_DEFINE3
- add ACKs
- CC: -> Cc: (suggested by Ingo Molnar)
- update comment in include/linux/syscalls.h (suggested by Ingo Molnar and Andy Lutomirski)
- separate declarations from definitions with newlines in include/linux/syscalls.h; add comment on ksys_close() (suggested by Ingo Molnar)
- expand commit messages (suggested by Christoph Hellwig)
- include patch 36:
fs: add ksys_open() wrapper; remove in-kernel calls to sys_open()
- do not worry about the following archs, as they are going away:

	cris, frv, metag, mn10300, score, tile
	(solving conflicts in -next)

- fix builds with CONFIG_FUTEX=n, CONFIG_ADVISE_SYSCALLS=n (solving issues found by Stephen Rothwell)

Thanks,
Dominik

Dominik Brodowski (36):
syscalls: define goal to not call sys_xyzzy() from within the kernel
kernel: use kernel_wait4() instead of sys_wait4()
mm: use do_futex() instead of sys_futex() in mm_release()
kernel: add do_getpgid() helper; remove internal call to sys_getpgid()
fs: add do_readlinkat() helper; remove internal call to
sys_readlinkat()
fs: add do_pipe2() helper; remove internal call to sys_pipe2()
fs: add do_renameat2() helper; remove internal call to sys_renameat2()
fs: add do_futimesat() helper; remove internal call to sys_futimesat()
syscalls: add do_epoll_*() helpers; remove internal calls to

    sys_epoll_*()
  fs: add do_signalfd4() helper; remove internal calls to
    sys_signalfd4()
  fs: add do_eventfd() helper; remove internal call to sys_eventfd()
  kernel: open-code sys_rt_sigpending() in sys_sigpending()
  x86/ioport: add ksys_ioperm() helper; remove in-kernel calls to
    sys_ioperm()
  fs: add ksys_mount() helper; remove in-kernel calls to sys_mount()
  fs: add ksys_umount() helper; remove in-kernel call to sys_umount()
  fs: add ksys_dup{,3}() helper; remove in-kernel calls to sys_dup{,3}()
  fs: add ksys_chroot() helper; remove-in kernel calls to sys_chroot()
  fs: add ksys_write() helper; remove in-kernel calls to sys_write()
  kernel: add ksys_unshare() helper; remove in-kernel calls to
    sys_unshare()
  mm: add ksys_fadvise64_64() helper; remove in-kernel call to
    sys_fadvise64_64()

mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to
sys_mmap_pgoff()
fs: add ksys_chdir() helper; remove in-kernel calls to sys_chdir()
fs: add ksys_sync_file_range helper(); remove in-kernel calls to
syscall
fs: add ksys_unlink() wrapper; remove in-kernel calls to sys_unlink()
hostfs: rename do_rmdir() to hostfs_do_rmdir()
fs: add ksys_rmdir() wrapper; remove in-kernel calls to sys_rmdir()
fs: add do_mkdirat() helper and ksys_mkdir() wrapper; remove in-kernel
calls to syscall
fs: add do_symlinkat() helper and ksys_symlink() wrapper; remove
in-kernel calls to syscall
fs: add do_mknodat() helper and ksys_mknod() wrapper; remove in-kernel
calls to syscall
fs: add do_linkat() helper and ksys_link() wrapper; remove in-kernel
calls to syscall
fs: add ksys_fchmod() and do_fchmodat() helpers and ksys_chmod()
wrapper; remove in-kernel calls to syscall
fs: add do_faccessat() helper and ksys_access() wrapper; remove
in-kernel calls to syscall
fs: add ksys_ftruncate() wrapper; remove in-kernel calls to
sys_ftruncate()
fs: add do_fchownat(), ksys_fchown() helpers and ksys_{,l}chown()
wrappers
fs: add ksys_close() wrapper; remove in-kernel calls to sys_close()
fs: add ksys_open() wrapper; remove in-kernel calls to sys_open()

 Documentation/process/adding-syscalls.rst |  14 ---
 arch/alpha/kernel/osf_sys.c               |   2 +-
 arch/arm/kernel/sys_arm.c                 |   2 +-
 arch/arm64/kernel/sys.c                   |   2 +-
 arch/ia64/kernel/sys_ia64.c               |   4 +-
 arch/m68k/kernel/sys_m68k.c               |   2 +-
 arch/microblaze/kernel/sys_microblaze.c   |   6 +-
 arch/mips/kernel/linux32.c                |  10 +-
 arch/mips/kernel/syscall.c                |   6 +-
 arch/parisc/kernel/sys_parisc.c           |  14 +--
 arch/powerpc/kernel/sys_ppc32.c           |   8 +-
 arch/powerpc/kernel/syscalls.c            |   6 +-
 arch/riscv/kernel/sys_riscv.c             |   4 +-
 arch/s390/kernel/compat_linux.c           |  23 ++---
 arch/s390/kernel/sys_s390.c               |   2 +-
 arch/sh/kernel/sys_sh.c                   |   4 +-
 arch/sh/kernel/sys_sh32.c                 |   8 +-
 arch/sparc/kernel/sys_sparc32.c           |  14 +--
 arch/sparc/kernel/sys_sparc_32.c          |   6 +-
 arch/sparc/kernel/sys_sparc_64.c          |   2 +-
 arch/um/kernel/syscall.c                  |   2 +-
 arch/x86/ia32/sys_ia32.c                  |  22 ++---
 arch/x86/include/asm/syscalls.h           |   1 +
 arch/x86/kernel/ioport.c                  |   7 +-
 arch/x86/kernel/sys_x86_64.c              |   2 +-
 arch/xtensa/kernel/syscall.c              |   2 +-
 drivers/base/devtmpfs.c                   |  11 ++-
 drivers/tty/vt/vt_ioctl.c                 |   6 +-
 fs/autofs4/dev-ioctl.c                    |   2 +-
 fs/binfmt_misc.c                          |   2 +-
 fs/eventfd.c                              |   9 +-
 fs/eventpoll.c                            |  23 +++--
 fs/file.c                                 |  17 +++-
 fs/hostfs/hostfs.h                        |   2 +-
 fs/hostfs/hostfs_kern.c                   |   2 +-
 fs/hostfs/hostfs_user.c                   |   2 +-
 fs/internal.h                             |  14 +++
 fs/namei.c                                |  61 +++++++++----
 fs/namespace.c                            |  19 +++-
 fs/open.c                                 |  68 ++++++++++----
 fs/pipe.c                                 |   9 +-
 fs/read_write.c                           |   9 +-
 fs/signalfd.c                             |  14 ++-
 fs/stat.c                                 |  12 ++-
 fs/sync.c                                 |  12 ++-
 fs/utimes.c                               |  13 ++-
 include/linux/futex.h                     |  13 ++-
 include/linux/syscalls.h                  | 146 +++++++++++++++++++++++++++++-
 init/do_mounts.c                          |  16 ++--
 init/do_mounts.h                          |   4 +-
 init/do_mounts_initrd.c                   |  38 ++++----
 init/do_mounts_md.c                       |  14 +--
 init/do_mounts_rd.c                       |  18 ++--
 init/initramfs.c                          |  48 +++++-----
 init/main.c                               |   9 +-
 init/noinitramfs.c                        |   6 +-
 kernel/exit.c                             |   2 +-
 kernel/fork.c                             |  11 ++-
 kernel/pid_namespace.c                    |   6 +-
 kernel/signal.c                           |  15 ++-
 kernel/sys.c                              |   9 +-
 kernel/uid16.c                            |   6 +-
 kernel/umh.c                              |   2 +-
 mm/fadvise.c                              |  10 +-
 mm/mmap.c                                 |  17 +++-
 mm/nommu.c                                |  17 +++-
 66 files changed, 614 insertions(+), 275 deletions(-)
Signature · 1 line
2.16.2