Skip to content

Commit 9d5b7c9

Browse files
author
Dominik Brodowski
committed
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: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent edf292c commit 9d5b7c9

12 files changed

Lines changed: 43 additions & 27 deletions

File tree

‎arch/arm/kernel/sys_arm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
3636
loff_t offset, loff_t len)
3737
{
38-
return sys_fadvise64_64(fd, offset, len, advice);
38+
return ksys_fadvise64_64(fd, offset, len, advice);
3939
}

‎arch/mips/kernel/linux32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
149149
unsigned long a4, unsigned long a5,
150150
int flags)
151151
{
152-
return sys_fadvise64_64(fd,
152+
return ksys_fadvise64_64(fd,
153153
merge_64(a2, a3), merge_64(a4, a5),
154154
flags);
155155
}

‎arch/parisc/kernel/sys_parisc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ asmlinkage long parisc_fadvise64_64(int fd,
352352
unsigned int high_off, unsigned int low_off,
353353
unsigned int high_len, unsigned int low_len, int advice)
354354
{
355-
return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
355+
return ksys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
356356
(loff_t)high_len << 32 | low_len, advice);
357357
}
358358

‎arch/powerpc/kernel/sys_ppc32.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long h
113113
long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
114114
size_t len, int advice)
115115
{
116-
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
117-
advice);
116+
return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low, len,
117+
advice);
118118
}
119119

120120
asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,

‎arch/powerpc/kernel/syscalls.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ long ppc64_personality(unsigned long personality)
119119
long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
120120
u32 len_high, u32 len_low)
121121
{
122-
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
123-
(u64)len_high << 32 | len_low, advice);
122+
return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low,
123+
(u64)len_high << 32 | len_low, advice);
124124
}
125125

126126
long sys_switch_endian(void)

‎arch/s390/kernel/compat_linux.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd, u32, high, u32, low, compat_size
483483
advise = POSIX_FADV_DONTNEED;
484484
else if (advise == 5)
485485
advise = POSIX_FADV_NOREUSE;
486-
return sys_fadvise64(fd, (unsigned long)high << 32 | low, len, advise);
486+
return ksys_fadvise64_64(fd, (unsigned long)high << 32 | low, len,
487+
advise);
487488
}
488489

489490
struct fadvise64_64_args {
@@ -503,7 +504,7 @@ COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, struct fadvise64_64_args __user *, arg
503504
a.advice = POSIX_FADV_DONTNEED;
504505
else if (a.advice == 5)
505506
a.advice = POSIX_FADV_NOREUSE;
506-
return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
507+
return ksys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
507508
}
508509

509510
COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, int, fd, u32, offhigh, u32, offlow,

‎arch/sh/kernel/sys_sh32.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
5252
u32 len0, u32 len1, int advice)
5353
{
5454
#ifdef __LITTLE_ENDIAN__
55-
return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
56-
(u64)len1 << 32 | len0, advice);
55+
return ksys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
56+
(u64)len1 << 32 | len0, advice);
5757
#else
58-
return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
59-
(u64)len0 << 32 | len1, advice);
58+
return ksys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
59+
(u64)len0 << 32 | len1, advice);
6060
#endif
6161
}

‎arch/sparc/kernel/sys_sparc32.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,18 @@ long compat_sys_fadvise64(int fd,
225225
unsigned long offlo,
226226
compat_size_t len, int advice)
227227
{
228-
return sys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
228+
return ksys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
229229
}
230230

231231
long compat_sys_fadvise64_64(int fd,
232232
unsigned long offhi, unsigned long offlo,
233233
unsigned long lenhi, unsigned long lenlo,
234234
int advice)
235235
{
236-
return sys_fadvise64_64(fd,
237-
(offhi << 32) | offlo,
238-
(lenhi << 32) | lenlo,
239-
advice);
236+
return ksys_fadvise64_64(fd,
237+
(offhi << 32) | offlo,
238+
(lenhi << 32) | lenlo,
239+
advice);
240240
}
241241

242242
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)

‎arch/x86/ia32/sys_ia32.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ COMPAT_SYSCALL_DEFINE6(x86_fadvise64_64, int, fd, __u32, offset_low,
194194
__u32, offset_high, __u32, len_low, __u32, len_high,
195195
int, advice)
196196
{
197-
return sys_fadvise64_64(fd,
198-
(((u64)offset_high)<<32) | offset_low,
199-
(((u64)len_high)<<32) | len_low,
200-
advice);
197+
return ksys_fadvise64_64(fd,
198+
(((u64)offset_high)<<32) | offset_low,
199+
(((u64)len_high)<<32) | len_low,
200+
advice);
201201
}
202202

203203
COMPAT_SYSCALL_DEFINE4(x86_readahead, int, fd, unsigned int, off_lo,
@@ -218,8 +218,8 @@ COMPAT_SYSCALL_DEFINE6(x86_sync_file_range, int, fd, unsigned int, off_low,
218218
COMPAT_SYSCALL_DEFINE5(x86_fadvise64, int, fd, unsigned int, offset_lo,
219219
unsigned int, offset_hi, size_t, len, int, advice)
220220
{
221-
return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
222-
len, advice);
221+
return ksys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
222+
len, advice);
223223
}
224224

225225
COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,

‎arch/xtensa/kernel/syscall.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
5555
asmlinkage long xtensa_fadvise64_64(int fd, int advice,
5656
unsigned long long offset, unsigned long long len)
5757
{
58-
return sys_fadvise64_64(fd, offset, len, advice);
58+
return ksys_fadvise64_64(fd, offset, len, advice);
5959
}
6060

6161
#ifdef CONFIG_MMU

0 commit comments

Comments
 (0)