Commit a8ca5d0e authored by Eric B Munson's avatar Eric B Munson Committed by Linus Torvalds

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: default avatarEric B Munson <>
Acked-by: default avatarMichal Hocko <>
Acked-by: default avatarVlastimil Babka <>
Cc: Heiko Carstens <>
Cc: Geert Uytterhoeven <>
Cc: Catalin Marinas <>
Cc: Stephen Rothwell <>
Cc: Guenter Roeck <>
Cc: Jonathan Corbet <>
Cc: Kirill A. Shutemov <>
Cc: Michael Kerrisk <>
Cc: Ralf Baechle <>
Cc: Shuah Khan <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 1aab92ec
......@@ -382,3 +382,4 @@
373 i386 shutdown sys_shutdown
374 i386 userfaultfd sys_userfaultfd
375 i386 membarrier sys_membarrier
376 i386 mlock2 sys_mlock2
......@@ -331,6 +331,7 @@
322 64 execveat stub_execveat
323 common userfaultfd sys_userfaultfd
324 common membarrier sys_membarrier
325 common mlock2 sys_mlock2
# x32-specific system call numbers start at 512 to avoid cache impact
......@@ -887,4 +887,6 @@ asmlinkage long sys_execveat(int dfd, const char __user *filename,
asmlinkage long sys_membarrier(int cmd, int flags);
asmlinkage long sys_mlock2(unsigned long start, size_t len, int flags);
......@@ -713,9 +713,11 @@ __SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat)
__SYSCALL(__NR_userfaultfd, sys_userfaultfd)
#define __NR_membarrier 283
__SYSCALL(__NR_membarrier, sys_membarrier)
#define __NR_mlock2 284
__SYSCALL(__NR_mlock2, sys_mlock2)
#undef __NR_syscalls
#define __NR_syscalls 284
#define __NR_syscalls 285
* All syscalls below here should go away really,
......@@ -194,6 +194,7 @@ cond_syscall(sys_mlock);
......@@ -644,6 +644,14 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
return do_mlock(start, len, VM_LOCKED);
SYSCALL_DEFINE3(mlock2, unsigned long, start, size_t, len, int, flags)
if (flags)
return -EINVAL;
return do_mlock(start, len, VM_LOCKED);
SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
int ret;
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