History

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.

Eric B Munson committed 11 years ago

Commit a8ca5d01 parent 1aab92e6 files · +16 −1Browse files

Unified · Split

6 files
  1. arch/x86/entry/syscalls/syscall_32.tbl +1 −0
  2. arch/x86/entry/syscalls/syscall_64.tbl +1 −0
  3. include/linux/syscalls.h +2 −0
  4. include/uapi/asm-generic/unistd.h +3 −1
  5. kernel/sys_ni.c +1 −0
  6. mm/mlock.c +8 −0
arch/x86/entry/syscalls/syscall_32.tbl+1−0
@@ -382,3 +382,4 @@ · 381 unmodified lines
382382 373 i386 shutdown sys_shutdown
383383 374 i386 userfaultfd sys_userfaultfd
384384 375 i386 membarrier sys_membarrier
385+376 i386 mlock2 sys_mlock2
arch/x86/entry/syscalls/syscall_64.tbl+1−0
@@ -331,6 +331,7 @@ · 330 unmodified lines
331331 322 64 execveat stub_execveat
332332 323 common userfaultfd sys_userfaultfd
333333 324 common membarrier sys_membarrier
334+325 common mlock2 sys_mlock2
334335
335336 #
336337 # x32-specific system call numbers start at 512 to avoid cache impact
include/linux/syscalls.h+2−0
@@ -887,4 +887,6 @@ asmlinkage long sys_execveat(int dfd, const char __user *filename, · 886 unmodified lines
887887
888888 asmlinkage long sys_membarrier(int cmd, int flags);
889889
890+asmlinkage long sys_mlock2(unsigned long start, size_t len, int flags);
891+
890892 #endif
include/uapi/asm-generic/unistd.h+3−1
@@ -713,9 +713,11 @@ __SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) · 712 unmodified lines
713713 __SYSCALL(__NR_userfaultfd, sys_userfaultfd)
714714 #define __NR_membarrier 283
715715 __SYSCALL(__NR_membarrier, sys_membarrier)
716+#define __NR_mlock2 284
717+__SYSCALL(__NR_mlock2, sys_mlock2)
716718
717719 #undef __NR_syscalls
718−#define __NR_syscalls 284
720+#define __NR_syscalls 285
719721
720722 /*
721723 * All syscalls below here should go away really,
kernel/sys_ni.c+1−0
@@ -194,6 +194,7 @@ cond_syscall(sys_mlock); · 193 unmodified lines
194194 cond_syscall(sys_munlock);
195195 cond_syscall(sys_mlockall);
196196 cond_syscall(sys_munlockall);
197+cond_syscall(sys_mlock2);
197198 cond_syscall(sys_mincore);
198199 cond_syscall(sys_madvise);
199200 cond_syscall(sys_mremap);
mm/mlock.c+8−0
@@ -644,6 +644,14 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len) · 643 unmodified lines
644644 return do_mlock(start, len, VM_LOCKED);
645645 }
646646
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+
647655 SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
648656 {
649657 int ret;