linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified
@ 2016-09-08  9:12 wei.guo.simon
  2016-09-08  9:12 ` [PATCH 1/3] mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages wei.guo.simon
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: wei.guo.simon @ 2016-09-08  9:12 UTC (permalink / raw)
  To: linux-mm
  Cc: Shuah Khan, Andrew Morton, Vlastimil Babka, Kirill A. Shutemov,
	Michal Hocko, Eric B Munson, Simon Guo, Mel Gorman,
	Alexey Klimov, Andrea Arcangeli, Thierry Reding, Mike Kravetz,
	Geert Uytterhoeven, linux-kernel, linux-kselftest

From: Simon Guo <wei.guo.simon@gmail.com>

The original mlock self tests are far from completed and David suggests
to elaborate that.

The patch set expand mlock selftest case by randomly mlock/mlock2 on
given memory region. It covers both under MLOCK rlimit and exceed MLOCK 
rlimit case.

During the testing, one bug was identified (introduced by my previous patch 
and sorry for that). Fix is included in this patch set.

Simon Guo (3):
  mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate
    VMLOCKED pages
  selftest: move seek_to_smaps_entry() out of mlock2-tests.c
  selftests: expanding more mlock selftest

 mm/mlock.c                                        |   6 +-
 tools/testing/selftests/vm/Makefile               |   4 +-
 tools/testing/selftests/vm/mlock-intersect-test.c |  76 ------
 tools/testing/selftests/vm/mlock-random-test.c    | 293 ++++++++++++++++++++++
 tools/testing/selftests/vm/mlock2-tests.c         |  42 ----
 tools/testing/selftests/vm/mlock2.h               |  43 ++++
 6 files changed, 342 insertions(+), 122 deletions(-)
 delete mode 100644 tools/testing/selftests/vm/mlock-intersect-test.c
 create mode 100644 tools/testing/selftests/vm/mlock-random-test.c

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages
  2016-09-08  9:12 [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified wei.guo.simon
@ 2016-09-08  9:12 ` wei.guo.simon
  2016-09-08  9:12 ` [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c wei.guo.simon
  2016-09-08  9:12 ` [PATCH 3/3] selftests: expanding more mlock selftest wei.guo.simon
  2 siblings, 0 replies; 4+ messages in thread
From: wei.guo.simon @ 2016-09-08  9:12 UTC (permalink / raw)
  To: linux-mm
  Cc: Shuah Khan, Andrew Morton, Vlastimil Babka, Kirill A. Shutemov,
	Michal Hocko, Eric B Munson, Simon Guo, Mel Gorman,
	Alexey Klimov, Andrea Arcangeli, Thierry Reding, Mike Kravetz,
	Geert Uytterhoeven, linux-kernel, linux-kselftest

From: Simon Guo <wei.guo.simon@gmail.com>

There is a typo/bug in count_mm_mlocked_page_nr() for "&" which is
mistakenly used with "&&".

Also add more checks and some minor change based on Kirill's previous
comment.

Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
---
 mm/mlock.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index fafbb78..145a425 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -641,9 +641,11 @@ static int count_mm_mlocked_page_nr(struct mm_struct *mm,
 		vma = mm->mmap;
 
 	for (; vma ; vma = vma->vm_next) {
+		if (start >= vma->vm_end)
+			continue;
 		if (start + len <=  vma->vm_start)
 			break;
-		if (vma->vm_flags && VM_LOCKED) {
+		if (vma->vm_flags & VM_LOCKED) {
 			if (start > vma->vm_start)
 				count -= (start - vma->vm_start);
 			if (start + len < vma->vm_end) {
@@ -654,7 +656,7 @@ static int count_mm_mlocked_page_nr(struct mm_struct *mm,
 		}
 	}
 
-	return (PAGE_ALIGN(count) >> PAGE_SHIFT);
+	return count >> PAGE_SHIFT;
 }
 
 static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t flags)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c
  2016-09-08  9:12 [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified wei.guo.simon
  2016-09-08  9:12 ` [PATCH 1/3] mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages wei.guo.simon
@ 2016-09-08  9:12 ` wei.guo.simon
  2016-09-08  9:12 ` [PATCH 3/3] selftests: expanding more mlock selftest wei.guo.simon
  2 siblings, 0 replies; 4+ messages in thread
From: wei.guo.simon @ 2016-09-08  9:12 UTC (permalink / raw)
  To: linux-mm
  Cc: Shuah Khan, Andrew Morton, Vlastimil Babka, Kirill A. Shutemov,
	Michal Hocko, Eric B Munson, Simon Guo, Mel Gorman,
	Alexey Klimov, Andrea Arcangeli, Thierry Reding, Mike Kravetz,
	Geert Uytterhoeven, linux-kernel, linux-kselftest

From: Simon Guo <wei.guo.simon@gmail.com>

Function seek_to_smaps_entry() can be useful for other selftest
functionalities, so move it out to header file.

Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
---
 tools/testing/selftests/vm/mlock2-tests.c | 42 ------------------------------
 tools/testing/selftests/vm/mlock2.h       | 43 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
index 7cb13ce..ff0cda2 100644
--- a/tools/testing/selftests/vm/mlock2-tests.c
+++ b/tools/testing/selftests/vm/mlock2-tests.c
@@ -1,8 +1,6 @@
 #define _GNU_SOURCE
 #include <sys/mman.h>
 #include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <sys/time.h>
@@ -119,46 +117,6 @@ static uint64_t get_kpageflags(unsigned long pfn)
 	return flags;
 }
 
-static FILE *seek_to_smaps_entry(unsigned long addr)
-{
-	FILE *file;
-	char *line = NULL;
-	size_t size = 0;
-	unsigned long start, end;
-	char perms[5];
-	unsigned long offset;
-	char dev[32];
-	unsigned long inode;
-	char path[BUFSIZ];
-
-	file = fopen("/proc/self/smaps", "r");
-	if (!file) {
-		perror("fopen smaps");
-		_exit(1);
-	}
-
-	while (getline(&line, &size, file) > 0) {
-		if (sscanf(line, "%lx-%lx %s %lx %s %lu %s\n",
-			   &start, &end, perms, &offset, dev, &inode, path) < 6)
-			goto next;
-
-		if (start <= addr && addr < end)
-			goto out;
-
-next:
-		free(line);
-		line = NULL;
-		size = 0;
-	}
-
-	fclose(file);
-	file = NULL;
-
-out:
-	free(line);
-	return file;
-}
-
 #define VMFLAGS "VmFlags:"
 
 static bool is_vmflag_set(unsigned long addr, const char *vmflag)
diff --git a/tools/testing/selftests/vm/mlock2.h b/tools/testing/selftests/vm/mlock2.h
index b9c6d9f..b2c09b4 100644
--- a/tools/testing/selftests/vm/mlock2.h
+++ b/tools/testing/selftests/vm/mlock2.h
@@ -1,5 +1,7 @@
 #include <syscall.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #ifndef MLOCK_ONFAULT
 #define MLOCK_ONFAULT 1
@@ -18,3 +20,44 @@ static int mlock2_(void *start, size_t len, int flags)
 	return -1;
 #endif
 }
+
+static FILE *seek_to_smaps_entry(unsigned long addr)
+{
+	FILE *file;
+	char *line = NULL;
+	size_t size = 0;
+	unsigned long start, end;
+	char perms[5];
+	unsigned long offset;
+	char dev[32];
+	unsigned long inode;
+	char path[BUFSIZ];
+
+	file = fopen("/proc/self/smaps", "r");
+	if (!file) {
+		perror("fopen smaps");
+		_exit(1);
+	}
+
+	while (getline(&line, &size, file) > 0) {
+		if (sscanf(line, "%lx-%lx %s %lx %s %lu %s\n",
+			   &start, &end, perms, &offset, dev, &inode, path) < 6)
+			goto next;
+
+		if (start <= addr && addr < end)
+			goto out;
+
+next:
+		free(line);
+		line = NULL;
+		size = 0;
+	}
+
+	fclose(file);
+	file = NULL;
+
+out:
+	free(line);
+	return file;
+}
+
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] selftests: expanding more mlock selftest
  2016-09-08  9:12 [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified wei.guo.simon
  2016-09-08  9:12 ` [PATCH 1/3] mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages wei.guo.simon
  2016-09-08  9:12 ` [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c wei.guo.simon
@ 2016-09-08  9:12 ` wei.guo.simon
  2 siblings, 0 replies; 4+ messages in thread
From: wei.guo.simon @ 2016-09-08  9:12 UTC (permalink / raw)
  To: linux-mm
  Cc: Shuah Khan, Andrew Morton, Vlastimil Babka, Kirill A. Shutemov,
	Michal Hocko, Eric B Munson, Simon Guo, Mel Gorman,
	Alexey Klimov, Andrea Arcangeli, Thierry Reding, Mike Kravetz,
	Geert Uytterhoeven, linux-kernel, linux-kselftest

From: Simon Guo <wei.guo.simon@gmail.com>

This patch will randomly perform mlock/mlock2 on a given
memory region, and verify the RLIMIT_MEMLOCK limitation
works properly.

Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
---
 tools/testing/selftests/vm/Makefile               |   4 +-
 tools/testing/selftests/vm/mlock-intersect-test.c |  76 ------
 tools/testing/selftests/vm/mlock-random-test.c    | 293 ++++++++++++++++++++++
 3 files changed, 295 insertions(+), 78 deletions(-)
 delete mode 100644 tools/testing/selftests/vm/mlock-intersect-test.c
 create mode 100644 tools/testing/selftests/vm/mlock-random-test.c

diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index a0412a8..bbab7f4 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -10,7 +10,7 @@ BINARIES += on-fault-limit
 BINARIES += thuge-gen
 BINARIES += transhuge-stress
 BINARIES += userfaultfd
-BINARIES += mlock-intersect-test
+BINARIES += mlock-random-test
 
 all: $(BINARIES)
 %: %.c
@@ -18,7 +18,7 @@ all: $(BINARIES)
 userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
 	$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
-mlock-intersect-test: mlock-intersect-test.c
+mlock-random-test: mlock-random-test.c
 	$(CC) $(CFLAGS) -o $@ $< -lcap
 
 ../../../../usr/include/linux/kernel.h:
diff --git a/tools/testing/selftests/vm/mlock-intersect-test.c b/tools/testing/selftests/vm/mlock-intersect-test.c
deleted file mode 100644
index f78e68a..0000000
--- a/tools/testing/selftests/vm/mlock-intersect-test.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * It tests the duplicate mlock result:
- * - the ulimit of lock page is 64k
- * - allocate address area 64k starting from p
- * - mlock   [p -- p + 30k]
- * - Then mlock address  [ p -- p + 40k ]
- *
- * It should succeed since totally we locked
- * 40k < 64k limitation.
- *
- * It should not be run with CAP_IPC_LOCK.
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/resource.h>
-#include <sys/capability.h>
-#include <sys/mman.h>
-#include "mlock2.h"
-
-int main(int argc, char **argv)
-{
-	struct rlimit new;
-	char *p = NULL;
-	cap_t cap = cap_init();
-	int i;
-
-	/* drop capabilities including CAP_IPC_LOCK */
-	if (cap_set_proc(cap))
-		return -1;
-
-	/* set mlock limits to 64k */
-	new.rlim_cur = 65536;
-	new.rlim_max = 65536;
-	setrlimit(RLIMIT_MEMLOCK, &new);
-
-	/* test VM_LOCK */
-	p = malloc(1024 * 64);
-	if (mlock(p, 1024 * 30)) {
-		printf("mlock() 30k return failure.\n");
-		return -1;
-	}
-	for (i = 0; i < 10; i++) {
-		if (mlock(p, 1024 * 40)) {
-			printf("mlock() #%d 40k returns failure.\n", i);
-			return -1;
-		}
-	}
-	for (i = 0; i < 10; i++) {
-		if (mlock2_(p, 1024 * 40, MLOCK_ONFAULT)) {
-			printf("mlock2_() #%d 40k returns failure.\n", i);
-			return -1;
-		}
-	}
-	free(p);
-
-	/* Test VM_LOCKONFAULT */
-	p = malloc(1024 * 64);
-	if (mlock2_(p, 1024 * 30, MLOCK_ONFAULT)) {
-		printf("mlock2_() 30k return failure.\n");
-		return -1;
-	}
-	for (i = 0; i < 10; i++) {
-		if (mlock2_(p, 1024 * 40, MLOCK_ONFAULT)) {
-			printf("mlock2_() #%d 40k returns failure.\n", i);
-			return -1;
-		}
-	}
-	for (i = 0; i < 10; i++) {
-		if (mlock(p, 1024 * 40)) {
-			printf("mlock() #%d 40k returns failure.\n", i);
-			return -1;
-		}
-	}
-	return 0;
-}
diff --git a/tools/testing/selftests/vm/mlock-random-test.c b/tools/testing/selftests/vm/mlock-random-test.c
new file mode 100644
index 0000000..83de4f5
--- /dev/null
+++ b/tools/testing/selftests/vm/mlock-random-test.c
@@ -0,0 +1,293 @@
+/*
+ * It tests the mlock/mlock2() when they are invoked
+ * on randomly memory region.
+ */
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/capability.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <time.h>
+#include "mlock2.h"
+
+#define CHUNK_UNIT (128 * 1024)
+#define MLOCK_RLIMIT_SIZE (CHUNK_UNIT * 2)
+#define MLOCK_WITHIN_LIMIT_SIZE CHUNK_UNIT
+#define MLOCK_OUTOF_LIMIT_SIZE (CHUNK_UNIT * 3)
+
+#define TEST_LOOP 100
+#define PAGE_ALIGN(size, ps) (((size) + ((ps) - 1)) & ~((ps) - 1))
+
+int set_cap_limits(rlim_t max)
+{
+	struct rlimit new;
+	cap_t cap = cap_init();
+
+	new.rlim_cur = max;
+	new.rlim_max = max;
+	if (setrlimit(RLIMIT_MEMLOCK, &new)) {
+		perror("setrlimit() returns error\n");
+		return -1;
+	}
+
+	/* drop capabilities including CAP_IPC_LOCK */
+	if (cap_set_proc(cap)) {
+		perror("cap_set_proc() returns error\n");
+		return -2;
+	}
+
+	return 0;
+}
+
+int get_proc_locked_vm_size(void)
+{
+	FILE *f;
+	int ret = -1;
+	char line[1024] = {0};
+	unsigned long lock_size = 0;
+
+	f = fopen("/proc/self/status", "r");
+	if (!f) {
+		perror("fopen");
+		return -1;
+	}
+
+	while (fgets(line, 1024, f)) {
+		if (strstr(line, "VmLck")) {
+			ret = sscanf(line, "VmLck:\t%8lu kB", &lock_size);
+			if (ret <= 0) {
+				printf("sscanf() on VmLck error: %s: %d\n",
+						line, ret);
+				fclose(f);
+				return -1;
+			}
+			fclose(f);
+			return (int)(lock_size << 10);
+		}
+	}
+
+	perror("cann't parse VmLck in /proc/self/status\n");
+	fclose(f);
+	return -1;
+}
+
+/*
+ * Get the MMUPageSize of the memory region including input
+ * address from proc file.
+ *
+ * return value: on error case, 0 will be returned.
+ * Otherwise the page size(in bytes) is returned.
+ */
+int get_proc_page_size(unsigned long addr)
+{
+	FILE *smaps;
+	char *line;
+	unsigned long mmupage_size = 0;
+	size_t size;
+
+	smaps = seek_to_smaps_entry(addr);
+	if (!smaps) {
+		printf("Unable to parse /proc/self/smaps\n");
+		return 0;
+	}
+
+	while (getline(&line, &size, smaps) > 0) {
+		if (!strstr(line, "MMUPageSize")) {
+			free(line);
+			line = NULL;
+			size = 0;
+			continue;
+		}
+
+		/* found the MMUPageSize of this section */
+		if (sscanf(line, "MMUPageSize:    %8lu kB",
+					&mmupage_size) < 1) {
+			printf("Unable to parse smaps entry for Size:%s\n",
+					line);
+			break;
+		}
+
+	}
+	free(line);
+	if (smaps)
+		fclose(smaps);
+	return mmupage_size << 10;
+}
+
+/*
+ * Test mlock/mlock2() on provided memory chunk.
+ * It expects the mlock/mlock2() to be successful (within rlimit)
+ *
+ * With allocated memory chunk [p, p + alloc_size), this
+ * test will choose start/len randomly to perform mlock/mlock2
+ * [start, start +  len] memory range. The range is within range
+ * of the allocated chunk.
+ *
+ * The memory region size alloc_size is within the rlimit.
+ * So we always expect a success of mlock/mlock2.
+ *
+ * VmLck is assumed to be 0 before this test.
+ *
+ *    return value: 0 - success
+ *    else: failure
+ */
+int test_mlock_within_limit(char *p, int alloc_size)
+{
+	int i;
+	int ret = 0;
+	int locked_vm_size = 0;
+	struct rlimit cur;
+	int page_size = 0;
+
+	getrlimit(RLIMIT_MEMLOCK, &cur);
+	if (cur.rlim_cur < alloc_size) {
+		printf("alloc_size[%d] < %u rlimit,lead to mlock failure\n",
+				alloc_size, (unsigned int)cur.rlim_cur);
+		return -1;
+	}
+
+	srand(time(NULL));
+	for (i = 0; i < TEST_LOOP; i++) {
+		/*
+		 * - choose mlock/mlock2 randomly
+		 * - choose lock_size randomly but lock_size < alloc_size
+		 * - choose start_offset randomly but p+start_offset+lock_size
+		 *   < p+alloc_size
+		 */
+		int is_mlock = !!(rand() % 2);
+		int lock_size = rand() % alloc_size;
+		int start_offset = rand() % (alloc_size - lock_size);
+
+		if (is_mlock)
+			ret = mlock(p + start_offset, lock_size);
+		else
+			ret = mlock2_(p + start_offset, lock_size,
+				       MLOCK_ONFAULT);
+
+		if (ret) {
+			printf("%s() failure at |%p(%d)| mlock:|%p(%d)|\n",
+					is_mlock ? "mlock" : "mlock2",
+					p, alloc_size,
+					p + start_offset, lock_size);
+			return ret;
+		}
+	}
+
+	/*
+	 * Check VmLck left by the tests.
+	 */
+	locked_vm_size = get_proc_locked_vm_size();
+	page_size = get_proc_page_size((unsigned long)p);
+	if (page_size == 0) {
+		printf("cannot get proc MMUPageSize\n");
+		return -1;
+	}
+
+	if (locked_vm_size > PAGE_ALIGN(alloc_size, page_size) + page_size) {
+		printf("test_mlock_within_limit() left VmLck:%d on %d chunk\n",
+				locked_vm_size, alloc_size);
+		return -1;
+	}
+
+	return 0;
+}
+
+
+/*
+ * We expect the mlock/mlock2() to be fail (outof limitation)
+ *
+ * With allocated memory chunk [p, p + alloc_size), this
+ * test will randomly choose start/len and perform mlock/mlock2
+ * on [start, start+len] range.
+ *
+ * The memory region size alloc_size is above the rlimit.
+ * And the len to be locked is higher than rlimit.
+ * So we always expect a failure of mlock/mlock2.
+ * No locked page number should be increased as a side effect.
+ *
+ *    return value: 0 - success
+ *    else: failure
+ */
+int test_mlock_outof_limit(char *p, int alloc_size)
+{
+	int i;
+	int ret = 0;
+	int locked_vm_size = 0, old_locked_vm_size = 0;
+	struct rlimit cur;
+
+	getrlimit(RLIMIT_MEMLOCK, &cur);
+	if (cur.rlim_cur >= alloc_size) {
+		printf("alloc_size[%d] >%u rlimit, violates test condition\n",
+				alloc_size, (unsigned int)cur.rlim_cur);
+		return -1;
+	}
+
+	old_locked_vm_size = get_proc_locked_vm_size();
+	srand(time(NULL));
+	for (i = 0; i < TEST_LOOP; i++) {
+		int is_mlock = !!(rand() % 2);
+		int lock_size = (rand() % (alloc_size - cur.rlim_cur))
+			+ cur.rlim_cur;
+		int start_offset = rand() % (alloc_size - lock_size);
+
+		if (is_mlock)
+			ret = mlock(p + start_offset, lock_size);
+		else
+			ret = mlock2_(p + start_offset, lock_size,
+					MLOCK_ONFAULT);
+		if (ret == 0) {
+			printf("%s() succeeds? on %p(%d) mlock%p(%d)\n",
+					is_mlock ? "mlock" : "mlock2",
+					p, alloc_size,
+					p + start_offset, lock_size);
+			return -1;
+		}
+	}
+
+	locked_vm_size = get_proc_locked_vm_size();
+	if (locked_vm_size != old_locked_vm_size) {
+		printf("tests leads to new mlocked page: old[%d], new[%d]\n",
+				old_locked_vm_size,
+				locked_vm_size);
+		return -1;
+	}
+
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	char *p = NULL;
+	int ret = 0;
+
+	if (set_cap_limits(MLOCK_RLIMIT_SIZE))
+		return -1;
+
+	p = malloc(MLOCK_WITHIN_LIMIT_SIZE);
+	if (p == NULL) {
+		perror("malloc() failure\n");
+		return -1;
+	}
+	ret = test_mlock_within_limit(p, MLOCK_WITHIN_LIMIT_SIZE);
+	if (ret)
+		return ret;
+	munlock(p, MLOCK_WITHIN_LIMIT_SIZE);
+	free(p);
+
+
+	p = malloc(MLOCK_OUTOF_LIMIT_SIZE);
+	if (p == NULL) {
+		perror("malloc() failure\n");
+		return -1;
+	}
+	ret = test_mlock_outof_limit(p, MLOCK_OUTOF_LIMIT_SIZE);
+	if (ret)
+		return ret;
+	munlock(p, MLOCK_OUTOF_LIMIT_SIZE);
+	free(p);
+
+	return 0;
+}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-08  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08  9:12 [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified wei.guo.simon
2016-09-08  9:12 ` [PATCH 1/3] mm: mlock: correct a typo in count_mm_mlocked_page_nr() for caculate VMLOCKED pages wei.guo.simon
2016-09-08  9:12 ` [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c wei.guo.simon
2016-09-08  9:12 ` [PATCH 3/3] selftests: expanding more mlock selftest wei.guo.simon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).