Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1478961 > unrolled thread

[PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified

Started bywei.guo.simon@gmail.com
First post2016-09-08 11:20 +0200
Last post2016-09-08 11:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified wei.guo.simon@gmail.com - 2016-09-08 11:20 +0200
    [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c wei.guo.simon@gmail.com - 2016-09-08 11:20 +0200

#1478961 — [PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified

Fromwei.guo.simon@gmail.com
Date2016-09-08 11:20 +0200
Subject[PATCH 0/3] mm: mlock: elaborate mlock selftest case and fix one bug identified
Message-ID<sf3F0-3UY-41@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1478965 — [PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c

Fromwei.guo.simon@gmail.com
Date2016-09-08 11:20 +0200
Subject[PATCH 2/3] selftest: move seek_to_smaps_entry() out of mlock2-tests.c
Message-ID<sf3F1-3UY-53@gated-at.bofh.it>
In reply to#1478961
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web