Commit 9d5b7c95 authored by Dominik Brodowski's avatar Dominik Brodowski

mm: add ksys_fadvise64_64() helper; remove in-kernel call to sys_fadvise64_64()

Using the ksys_fadvise64_64() helper allows us to avoid the in-kernel
calls to the sys_fadvise64_64() syscall. The ksys_ prefix denotes that
this function is meant as a drop-in replacement for the syscall. In
particular, it uses the same calling convention as ksys_fadvise64_64().

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.

This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent edf292c7
...@@ -35,5 +35,5 @@ ...@@ -35,5 +35,5 @@
asmlinkage long sys_arm_fadvise64_64(int fd, int advice, asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
loff_t offset, loff_t len) loff_t offset, loff_t len)
{ {
return sys_fadvise64_64(fd, offset, len, advice); return ksys_fadvise64_64(fd, offset, len, advice);
} }
...@@ -149,7 +149,7 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad, ...@@ -149,7 +149,7 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
unsigned long a4, unsigned long a5, unsigned long a4, unsigned long a5,
int flags) int flags)
{ {
return sys_fadvise64_64(fd, return ksys_fadvise64_64(fd,
merge_64(a2, a3), merge_64(a4, a5), merge_64(a2, a3), merge_64(a4, a5),
flags); flags);
} }
......
...@@ -352,7 +352,7 @@ asmlinkage long parisc_fadvise64_64(int fd, ...@@ -352,7 +352,7 @@ asmlinkage long parisc_fadvise64_64(int fd,
unsigned int high_off, unsigned int low_off, unsigned int high_off, unsigned int low_off,
unsigned int high_len, unsigned int low_len, int advice) 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); (loff_t)high_len << 32 | low_len, advice);
} }
......
...@@ -113,7 +113,7 @@ asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long h ...@@ -113,7 +113,7 @@ 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, long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
size_t len, int advice) size_t len, int advice)
{ {
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len, return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low, len,
advice); advice);
} }
......
...@@ -119,7 +119,7 @@ long ppc64_personality(unsigned long personality) ...@@ -119,7 +119,7 @@ long ppc64_personality(unsigned long personality)
long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low, long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
u32 len_high, u32 len_low) u32 len_high, u32 len_low)
{ {
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low,
(u64)len_high << 32 | len_low, advice); (u64)len_high << 32 | len_low, advice);
} }
......
...@@ -483,7 +483,8 @@ COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, high, u32, low, compat_size ...@@ -483,7 +483,8 @@ COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, high, u32, low, compat_size
advise = POSIX_FADV_DONTNEED; advise = POSIX_FADV_DONTNEED;
else if (advise == 5) else if (advise == 5)
advise = POSIX_FADV_NOREUSE; 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 { struct fadvise64_64_args {
...@@ -503,7 +504,7 @@ COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, arg ...@@ -503,7 +504,7 @@ COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, arg
a.advice = POSIX_FADV_DONTNEED; a.advice = POSIX_FADV_DONTNEED;
else if (a.advice == 5) else if (a.advice == 5)
a.advice = POSIX_FADV_NOREUSE; 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, COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,
......
...@@ -52,10 +52,10 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, ...@@ -52,10 +52,10 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
u32 len0, u32 len1, int advice) u32 len0, u32 len1, int advice)
{ {
#ifdef __LITTLE_ENDIAN__ #ifdef __LITTLE_ENDIAN__
return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0, return ksys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
(u64)len1 << 32 | len0, advice); (u64)len1 << 32 | len0, advice);
#else #else
return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1, return ksys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
(u64)len0 << 32 | len1, advice); (u64)len0 << 32 | len1, advice);
#endif #endif
} }
...@@ -225,7 +225,7 @@ long compat_sys_fadvise64(int fd, ...@@ -225,7 +225,7 @@ long compat_sys_fadvise64(int fd,
unsigned long offlo, unsigned long offlo,
compat_size_t len, int advice) 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, long compat_sys_fadvise64_64(int fd,
...@@ -233,7 +233,7 @@ long compat_sys_fadvise64_64(int fd, ...@@ -233,7 +233,7 @@ long compat_sys_fadvise64_64(int fd,
unsigned long lenhi, unsigned long lenlo, unsigned long lenhi, unsigned long lenlo,
int advice) int advice)
{ {
return sys_fadvise64_64(fd, return ksys_fadvise64_64(fd,
(offhi << 32) | offlo, (offhi << 32) | offlo,
(lenhi << 32) | lenlo, (lenhi << 32) | lenlo,
advice); advice);
......
...@@ -194,7 +194,7 @@ COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low, ...@@ -194,7 +194,7 @@ COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low,
__u32, offset_high, __u32, len_low, __u32, len_high, __u32, offset_high, __u32, len_low, __u32, len_high,
int, advice) int, advice)
{ {
return sys_fadvise64_64(fd, return ksys_fadvise64_64(fd,
(((u64)offset_high)<<32) | offset_low, (((u64)offset_high)<<32) | offset_low,
(((u64)len_high)<<32) | len_low, (((u64)len_high)<<32) | len_low,
advice); advice);
...@@ -218,7 +218,7 @@ COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low, ...@@ -218,7 +218,7 @@ COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo, COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
unsigned int, offset_hi, size_t, len, int, advice) unsigned int, offset_hi, size_t, len, int, advice)
{ {
return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo, return ksys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
len, advice); len, advice);
} }
......
...@@ -55,7 +55,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg) ...@@ -55,7 +55,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
asmlinkage long xtensa_fadvise64_64(int fd, int advice, asmlinkage long xtensa_fadvise64_64(int fd, int advice,
unsigned long long offset, unsigned long long len) 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 #ifdef CONFIG_MMU
......
...@@ -970,6 +970,15 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count, ...@@ -970,6 +970,15 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count,
ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf, ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf,
size_t count, loff_t pos); size_t count, loff_t pos);
int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len); int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len);
#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
/* /*
* The following kernel syscall equivalents are just wrappers to fs-internal * The following kernel syscall equivalents are just wrappers to fs-internal
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could * POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
* deactivate the pages and clear PG_Referenced. * 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 fd f = fdget(fd);
struct inode *inode; struct inode *inode;
...@@ -185,11 +186,16 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) ...@@ -185,11 +186,16 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
return ret; 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 #ifdef __ARCH_WANT_SYS_FADVISE64
SYSCALL_DEFINE4(fadvise64, int, fd, loff_t, offset, size_t, len, int, advice) 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 #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment