All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	viro@zeniv.linux.org.uk
Cc: luto@kernel.org, mingo@kernel.org, akpm@linux-foundation.org,
	arnd@arndb.de, linux-mm@kvack.org
Subject: [PATCH v2 20/36] mm: add ksys_fadvise64_64() helper; remove in-kernel call to sys_fadvise64_64()
Date: Thu, 15 Mar 2018 20:05:13 +0100	[thread overview]
Message-ID: <20180315190529.20943-21-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180315190529.20943-1-linux@dominikbrodowski.net>

Using the ksys_fadvise64_64() helper allows us to avoid the in-kernel
calls to the sys_fadvise64_64() syscall.

Some compat stubs called sys_fadvise64(), which then just passed
through the arguments to sys_fadvise64_64(). Get rid of this
indirection, and call ksys_fadvise64_64() directly.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 arch/arm/kernel/sys_arm.c       |  2 +-
 arch/mips/kernel/linux32.c      |  2 +-
 arch/parisc/kernel/sys_parisc.c |  2 +-
 arch/powerpc/kernel/sys_ppc32.c |  4 ++--
 arch/powerpc/kernel/syscalls.c  |  4 ++--
 arch/s390/kernel/compat_linux.c |  5 +++--
 arch/sh/kernel/sys_sh32.c       |  8 ++++----
 arch/sparc/kernel/sys_sparc32.c | 10 +++++-----
 arch/x86/ia32/sys_ia32.c        | 12 ++++++------
 arch/xtensa/kernel/syscall.c    |  2 +-
 include/linux/syscalls.h        |  9 +++++++++
 mm/fadvise.c                    | 10 ++++++++--
 12 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 3151f5623d0e..bdf7514204ab 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -35,5 +35,5 @@
 asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
 				     loff_t offset, loff_t len)
 {
-	return sys_fadvise64_64(fd, offset, len, advice);
+	return ksys_fadvise64_64(fd, offset, len, advice);
 }
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index b332f6fc1e72..b8a3cf5d5950 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -149,7 +149,7 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
 	unsigned long a4, unsigned long a5,
 	int flags)
 {
-	return sys_fadvise64_64(fd,
+	return ksys_fadvise64_64(fd,
 			merge_64(a2, a3), merge_64(a4, a5),
 			flags);
 }
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 378a754ca186..da1c27ea8e1a 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -352,7 +352,7 @@ asmlinkage long parisc_fadvise64_64(int fd,
 			unsigned int high_off, unsigned int low_off,
 			unsigned int high_len, unsigned int low_len, int advice)
 {
-	return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
+	return ksys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
 			(loff_t)high_len << 32 | low_len, advice);
 }
 
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 15f216d022e2..93df264ab76c 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -113,8 +113,8 @@ asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long h
 long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
 		     size_t len, int advice)
 {
-	return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
-			     advice);
+	return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low, len,
+				 advice);
 }
 
 asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index a877bf8269fe..ecb981eea74b 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -119,8 +119,8 @@ long ppc64_personality(unsigned long personality)
 long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
 		      u32 len_high, u32 len_low)
 {
-	return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
-			     (u64)len_high << 32 | len_low, advice);
+	return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low,
+				 (u64)len_high << 32 | len_low, advice);
 }
 
 long sys_switch_endian(void)
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 5a9cfde5fc28..357a66934a98 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -483,7 +483,8 @@ COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, high, u32, low, compat_size
 		advise = POSIX_FADV_DONTNEED;
 	else if (advise == 5)
 		advise = POSIX_FADV_NOREUSE;
-	return sys_fadvise64(fd, (unsigned long)high << 32 | low, len, advise);
+	return ksys_fadvise64_64(fd, (unsigned long)high << 32 | low, len,
+				 advise);
 }
 
 struct fadvise64_64_args {
@@ -503,7 +504,7 @@ COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, arg
 		a.advice = POSIX_FADV_DONTNEED;
 	else if (a.advice == 5)
 		a.advice = POSIX_FADV_NOREUSE;
-	return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
+	return ksys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
 }
 
 COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c
index f8dc8bfd4606..4d55318e0899 100644
--- a/arch/sh/kernel/sys_sh32.c
+++ b/arch/sh/kernel/sys_sh32.c
@@ -52,10 +52,10 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
 				u32 len0, u32 len1, int advice)
 {
 #ifdef  __LITTLE_ENDIAN__
-	return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
-				(u64)len1 << 32 | len0,	advice);
+	return ksys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
+				 (u64)len1 << 32 | len0, advice);
 #else
-	return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
-				(u64)len0 << 32 | len1,	advice);
+	return ksys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
+				 (u64)len0 << 32 | len1, advice);
 #endif
 }
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index 6d964bdefbaa..08261bc15d30 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -225,7 +225,7 @@ long compat_sys_fadvise64(int fd,
 			  unsigned long offlo,
 			  compat_size_t len, int advice)
 {
-	return sys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
+	return ksys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
 }
 
 long compat_sys_fadvise64_64(int fd,
@@ -233,10 +233,10 @@ long compat_sys_fadvise64_64(int fd,
 			     unsigned long lenhi, unsigned long lenlo,
 			     int advice)
 {
-	return sys_fadvise64_64(fd,
-				(offhi << 32) | offlo,
-				(lenhi << 32) | lenlo,
-				advice);
+	return ksys_fadvise64_64(fd,
+				 (offhi << 32) | offlo,
+				 (lenhi << 32) | lenlo,
+				 advice);
 }
 
 long sys32_sync_file_range(unsigned int fd, unsigned long off_high, unsigned long off_low, unsigned long nb_high, unsigned long nb_low, unsigned int flags)
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index 6512498bbef6..2afd718e7422 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -198,10 +198,10 @@ COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low,
 		       __u32, offset_high, __u32, len_low, __u32, len_high,
 		       int, advice)
 {
-	return sys_fadvise64_64(fd,
-			       (((u64)offset_high)<<32) | offset_low,
-			       (((u64)len_high)<<32) | len_low,
-				advice);
+	return ksys_fadvise64_64(fd,
+				 (((u64)offset_high)<<32) | offset_low,
+				 (((u64)len_high)<<32) | len_low,
+				 advice);
 }
 
 COMPAT_SYSCALL_DEFINE4(x86_readahead, int, fd, unsigned int, off_lo,
@@ -222,8 +222,8 @@ COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
 COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
 		       unsigned int, offset_hi, size_t, len, int, advice)
 {
-	return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
-				len, advice);
+	return ksys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
+				 len, advice);
 }
 
 COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
index 74afbf02d07e..8201748da05b 100644
--- a/arch/xtensa/kernel/syscall.c
+++ b/arch/xtensa/kernel/syscall.c
@@ -55,7 +55,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
 asmlinkage long xtensa_fadvise64_64(int fd, int advice,
 		unsigned long long offset, unsigned long long len)
 {
-	return sys_fadvise64_64(fd, offset, len, advice);
+	return ksys_fadvise64_64(fd, offset, len, advice);
 }
 
 #ifdef CONFIG_MMU
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 2c0fabc7d19d..863ca7d6face 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -955,5 +955,14 @@ int ksys_dup(unsigned int fildes);
 int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_unshare(unsigned long unshare_flags);
+#ifdef CONFIG_ADVISE_SYSCALLS
+int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice);
+#else
+static inline int ksys_fadvise64_64(int fd, loff_t offset, loff_t len,
+				    int advice)
+{
+	return -EINVAL;
+}
+#endif
 
 #endif
diff --git a/mm/fadvise.c b/mm/fadvise.c
index 767887f5f3bf..afa41491d324 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -26,7 +26,8 @@
  * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
  * deactivate the pages and clear PG_Referenced.
  */
-SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
+
+int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
 {
 	struct fd f = fdget(fd);
 	struct inode *inode;
@@ -185,11 +186,16 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
 	return ret;
 }
 
+SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
+{
+	return ksys_fadvise64_64(fd, offset, len, advice);
+}
+
 #ifdef __ARCH_WANT_SYS_FADVISE64
 
 SYSCALL_DEFINE4(fadvise64, int, fd, loff_t, offset, size_t, len, int, advice)
 {
-	return sys_fadvise64_64(fd, offset, len, advice);
+	return ksys_fadvise64_64(fd, offset, len, advice);
 }
 
 #endif
-- 
2.16.2

  parent reply	other threads:[~2018-03-15 19:09 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 19:04 [PATCH v2 00/36] remove in-kernel syscall invocations (part 1) Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 01/36] syscalls: define goal to not call sys_xyzzy() from within the kernel Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 02/36] kernel: use kernel_wait4() instead of sys_wait4() Dominik Brodowski
2018-03-16 16:58   ` Luis R. Rodriguez
2018-03-17 16:44     ` Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 03/36] mm: use do_futex() instead of sys_futex() in mm_release() Dominik Brodowski
2018-03-16 11:58   ` Thomas Gleixner
2018-03-16 18:43   ` Darren Hart
2018-03-16 19:03     ` Andy Lutomirski
2018-03-16 21:44       ` Darren Hart
2018-03-17 16:39         ` Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 04/36] kernel: add do_getpgid() helper; remove internal call to sys_getpgid() Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 05/36] fs: add do_readlinkat() helper; remove internal call to sys_readlinkat() Dominik Brodowski
2018-03-15 19:04 ` [PATCH v2 06/36] fs: add do_pipe2() helper; remove internal call to sys_pipe2() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 07/36] fs: add do_renameat2() helper; remove internal call to sys_renameat2() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 08/36] fs: add do_futimesat() helper; remove internal call to sys_futimesat() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 09/36] syscalls: add do_epoll_*() helpers; remove internal calls to sys_epoll_*() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 10/36] fs: add do_signalfd4() helper; remove internal calls to sys_signalfd4() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 11/36] fs: add do_eventfd() helper; remove internal call to sys_eventfd() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 12/36] kernel: open-code sys_rt_sigpending() in sys_sigpending() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 13/36] x86/ioport: add ksys_ioperm() helper; remove in-kernel calls to sys_ioperm() Dominik Brodowski
2018-03-16  8:43   ` Christoph Hellwig
2018-03-16 11:13     ` Dominik Brodowski
2018-03-16 12:00   ` Thomas Gleixner
2018-03-16 14:45     ` Dominik Brodowski
2018-03-16 14:47       ` Thomas Gleixner
2018-03-15 19:05 ` [PATCH v2 14/36] fs: add ksys_mount() helper; remove in-kernel calls to sys_mount() Dominik Brodowski
2018-03-15 20:11   ` Arnd Bergmann
2018-03-16  8:46     ` Christoph Hellwig
2018-03-16 16:58     ` Linus Torvalds
2018-03-17 16:52     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 15/36] fs: add ksys_umount() helper; remove in-kernel call to sys_umount() Dominik Brodowski
2018-03-16  8:47   ` Christoph Hellwig
2018-03-17 16:58     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 16/36] fs: add ksys_dup{,3}() helper; remove in-kernel calls to sys_dup{,3}() Dominik Brodowski
2018-03-16  8:48   ` Christoph Hellwig
2018-03-17 17:01     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 17/36] fs: add ksys_chroot() helper; remove-in kernel calls to sys_chroot() Dominik Brodowski
2018-03-15 20:44   ` Arnd Bergmann
2018-03-16  8:49     ` Christoph Hellwig
2018-03-17 17:04     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 18/36] fs: add ksys_write() helper; remove in-kernel calls to sys_write() Dominik Brodowski
2018-03-16  8:52   ` Christoph Hellwig
2018-03-17 17:06     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 19/36] kernel: add ksys_unshare() helper; remove in-kernel calls to sys_unshare() Dominik Brodowski
2018-03-15 19:05 ` Dominik Brodowski [this message]
2018-03-15 19:05 ` [PATCH v2 21/36] mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff() Dominik Brodowski
2018-03-15 20:54   ` Arnd Bergmann
2018-03-15 19:05 ` [PATCH v2 22/36] fs: add ksys_chdir() helper; remove in-kernel calls to sys_chdir() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 23/36] fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscall Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 24/36] fs: add ksys_unlink() wrapper; remove in-kernel calls to sys_unlink() Dominik Brodowski
2018-03-15 20:21   ` Arnd Bergmann
2018-03-17 17:09     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 25/36] hostfs: rename do_rmdir() to hostfs_do_rmdir() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 26/36] fs: add ksys_rmdir() wrapper; remove in-kernel calls to sys_rmdir() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 27/36] fs: add do_mkdirat() helper and ksys_mkdir() wrapper; remove in-kernel calls to syscall Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 28/36] fs: add do_symlinkat() helper and ksys_symlink() " Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 29/36] fs: add do_mknodat() helper and ksys_mknod() " Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 30/36] fs: add do_linkat() helper and ksys_link() " Dominik Brodowski
2018-03-15 20:30   ` Arnd Bergmann
2018-03-17 17:11     ` Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 31/36] fs: add ksys_fchmod() and do_fchmodat() helpers and ksys_chmod() " Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 32/36] fs: add do_faccessat() helper and ksys_access() " Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 33/36] fs: add ksys_ftruncate() wrapper; remove in-kernel calls to sys_ftruncate() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 34/36] fs: add do_fchownat(), ksys_fchown() helpers and ksys_{,l}chown() wrappers Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 35/36] fs: add ksys_close() wrapper; remove in-kernel calls to sys_close() Dominik Brodowski
2018-03-15 19:05 ` [PATCH v2 36/36] fs: add ksys_open() wrapper; remove in-kernel calls to sys_open() Dominik Brodowski
2018-03-15 21:02 ` [PATCH v2 00/36] remove in-kernel syscall invocations (part 1) Arnd Bergmann
2018-03-16  0:38   ` Andy Lutomirski
2018-03-16  0:54     ` Linus Torvalds
2018-03-16  8:54       ` Christoph Hellwig
2018-03-16 14:20         ` Al Viro
2018-03-16 16:47           ` Linus Torvalds
2018-03-17 17:13   ` Dominik Brodowski
2018-03-16  9:01 ` Zhang, Ning A
2018-03-16 10:25   ` Dominik Brodowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180315190529.20943-21-linux@dominikbrodowski.net \
    --to=linux@dominikbrodowski.net \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.