diff options
author | Eric B Munson <emunson@akamai.com> | 2015-11-05 21:51:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
commit | a8ca5d0ecbdde5cc3d7accacbd69968b0c98764e (patch) | |
tree | d2f49d50d2fc30d86c364909a7095c752dfd5e4d | |
parent | 1aab92ec3de552362397b718744872ea2d17add2 (diff) |
mm: mlock: add new mlock system call
With the refactored mlock code, introduce a new system call for mlock.
The new call will allow the user to specify what lock states are being
added. mlock2 is trivial at the moment, but a follow on patch will add a
new mlock state making it useful.
Signed-off-by: Eric B Munson <emunson@akamai.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/entry/syscalls/syscall_32.tbl | 1 | ||||
-rw-r--r-- | arch/x86/entry/syscalls/syscall_64.tbl | 1 | ||||
-rw-r--r-- | include/linux/syscalls.h | 2 | ||||
-rw-r--r-- | include/uapi/asm-generic/unistd.h | 4 | ||||
-rw-r--r-- | kernel/sys_ni.c | 1 | ||||
-rw-r--r-- | mm/mlock.c | 8 |
6 files changed, 16 insertions, 1 deletions
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index caa2c712d1e7..f17705e1332c 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl | |||
@@ -382,3 +382,4 @@ | |||
382 | 373 i386 shutdown sys_shutdown | 382 | 373 i386 shutdown sys_shutdown |
383 | 374 i386 userfaultfd sys_userfaultfd | 383 | 374 i386 userfaultfd sys_userfaultfd |
384 | 375 i386 membarrier sys_membarrier | 384 | 375 i386 membarrier sys_membarrier |
385 | 376 i386 mlock2 sys_mlock2 | ||
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 278842fdf1f6..314a90bfc09c 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl | |||
@@ -331,6 +331,7 @@ | |||
331 | 322 64 execveat stub_execveat | 331 | 322 64 execveat stub_execveat |
332 | 323 common userfaultfd sys_userfaultfd | 332 | 323 common userfaultfd sys_userfaultfd |
333 | 324 common membarrier sys_membarrier | 333 | 324 common membarrier sys_membarrier |
334 | 325 common mlock2 sys_mlock2 | ||
334 | 335 | ||
335 | # | 336 | # |
336 | # x32-specific system call numbers start at 512 to avoid cache impact | 337 | # x32-specific system call numbers start at 512 to avoid cache impact |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index a460e2ef2843..a156b82dd14c 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -887,4 +887,6 @@ asmlinkage long sys_execveat(int dfd, const char __user *filename, | |||
887 | 887 | ||
888 | asmlinkage long sys_membarrier(int cmd, int flags); | 888 | asmlinkage long sys_membarrier(int cmd, int flags); |
889 | 889 | ||
890 | asmlinkage long sys_mlock2(unsigned long start, size_t len, int flags); | ||
891 | |||
890 | #endif | 892 | #endif |
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index ee124009e12a..1324b0292ec2 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h | |||
@@ -713,9 +713,11 @@ __SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) | |||
713 | __SYSCALL(__NR_userfaultfd, sys_userfaultfd) | 713 | __SYSCALL(__NR_userfaultfd, sys_userfaultfd) |
714 | #define __NR_membarrier 283 | 714 | #define __NR_membarrier 283 |
715 | __SYSCALL(__NR_membarrier, sys_membarrier) | 715 | __SYSCALL(__NR_membarrier, sys_membarrier) |
716 | #define __NR_mlock2 284 | ||
717 | __SYSCALL(__NR_mlock2, sys_mlock2) | ||
716 | 718 | ||
717 | #undef __NR_syscalls | 719 | #undef __NR_syscalls |
718 | #define __NR_syscalls 284 | 720 | #define __NR_syscalls 285 |
719 | 721 | ||
720 | /* | 722 | /* |
721 | * All syscalls below here should go away really, | 723 | * All syscalls below here should go away really, |
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index a02decf15583..0623787ec67a 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
@@ -194,6 +194,7 @@ cond_syscall(sys_mlock); | |||
194 | cond_syscall(sys_munlock); | 194 | cond_syscall(sys_munlock); |
195 | cond_syscall(sys_mlockall); | 195 | cond_syscall(sys_mlockall); |
196 | cond_syscall(sys_munlockall); | 196 | cond_syscall(sys_munlockall); |
197 | cond_syscall(sys_mlock2); | ||
197 | cond_syscall(sys_mincore); | 198 | cond_syscall(sys_mincore); |
198 | cond_syscall(sys_madvise); | 199 | cond_syscall(sys_madvise); |
199 | cond_syscall(sys_mremap); | 200 | cond_syscall(sys_mremap); |
diff --git a/mm/mlock.c b/mm/mlock.c index fbd8c03f7b37..35dcf8fa7195 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -644,6 +644,14 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len) | |||
644 | return do_mlock(start, len, VM_LOCKED); | 644 | return do_mlock(start, len, VM_LOCKED); |
645 | } | 645 | } |
646 | 646 | ||
647 | SYSCALL_DEFINE3(mlock2, unsigned long, start, size_t, len, int, flags) | ||
648 | { | ||
649 | if (flags) | ||
650 | return -EINVAL; | ||
651 | |||
652 | return do_mlock(start, len, VM_LOCKED); | ||
653 | } | ||
654 | |||
647 | SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) | 655 | SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) |
648 | { | 656 | { |
649 | int ret; | 657 | int ret; |