diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-08 20:52:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-08 20:52:23 -0400 |
commit | f6f7a6369203fa3e07efb7f35cfd81efe9f25b07 (patch) | |
tree | 97bec9ddd999040822acf314647eaf4208213589 /tools/testing | |
parent | 839fe9156fbe89c3157aa6146d22090f8cffddd8 (diff) | |
parent | df69f52d990bd85159727bd26e819d3a6e49c666 (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge second patch-bomb from Andrew Morton:
"Almost all of the rest of MM. There was an unusually large amount of
MM material this time"
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (141 commits)
zpool: remove no-op module init/exit
mm: zbud: constify the zbud_ops
mm: zpool: constify the zpool_ops
mm: swap: zswap: maybe_preload & refactoring
zram: unify error reporting
zsmalloc: remove null check from destroy_handle_cache()
zsmalloc: do not take class lock in zs_shrinker_count()
zsmalloc: use class->pages_per_zspage
zsmalloc: consider ZS_ALMOST_FULL as migrate source
zsmalloc: partial page ordering within a fullness_list
zsmalloc: use shrinker to trigger auto-compaction
zsmalloc: account the number of compacted pages
zsmalloc/zram: introduce zs_pool_stats api
zsmalloc: cosmetic compaction code adjustments
zsmalloc: introduce zs_can_compact() function
zsmalloc: always keep per-class stats
zsmalloc: drop unused variable `nr_to_migrate'
mm/memblock.c: fix comment in __next_mem_range()
mm/page_alloc.c: fix type information of memoryless node
memory-hotplug: fix comments in zone_spanned_pages_in_node() and zone_spanned_pages_in_node()
...
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/vm/Makefile | 1 | ||||
-rw-r--r-- | tools/testing/selftests/vm/hugetlbfstest.c | 86 | ||||
-rwxr-xr-x | tools/testing/selftests/vm/run_vmtests | 13 | ||||
-rw-r--r-- | tools/testing/selftests/vm/userfaultfd.c | 9 |
4 files changed, 9 insertions, 100 deletions
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 0d6854744b37..d36fab7d8ebd 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -4,7 +4,6 @@ CFLAGS = -Wall | |||
4 | BINARIES = compaction_test | 4 | BINARIES = compaction_test |
5 | BINARIES += hugepage-mmap | 5 | BINARIES += hugepage-mmap |
6 | BINARIES += hugepage-shm | 6 | BINARIES += hugepage-shm |
7 | BINARIES += hugetlbfstest | ||
8 | BINARIES += map_hugetlb | 7 | BINARIES += map_hugetlb |
9 | BINARIES += thuge-gen | 8 | BINARIES += thuge-gen |
10 | BINARIES += transhuge-stress | 9 | BINARIES += transhuge-stress |
diff --git a/tools/testing/selftests/vm/hugetlbfstest.c b/tools/testing/selftests/vm/hugetlbfstest.c deleted file mode 100644 index 02e1072ec187..000000000000 --- a/tools/testing/selftests/vm/hugetlbfstest.c +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | #define _GNU_SOURCE | ||
2 | #include <assert.h> | ||
3 | #include <fcntl.h> | ||
4 | #include <stdio.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <string.h> | ||
7 | #include <sys/mman.h> | ||
8 | #include <sys/stat.h> | ||
9 | #include <sys/types.h> | ||
10 | #include <unistd.h> | ||
11 | |||
12 | typedef unsigned long long u64; | ||
13 | |||
14 | static size_t length = 1 << 24; | ||
15 | |||
16 | static u64 read_rss(void) | ||
17 | { | ||
18 | char buf[4096], *s = buf; | ||
19 | int i, fd; | ||
20 | u64 rss; | ||
21 | |||
22 | fd = open("/proc/self/statm", O_RDONLY); | ||
23 | assert(fd > 2); | ||
24 | memset(buf, 0, sizeof(buf)); | ||
25 | read(fd, buf, sizeof(buf) - 1); | ||
26 | for (i = 0; i < 1; i++) | ||
27 | s = strchr(s, ' ') + 1; | ||
28 | rss = strtoull(s, NULL, 10); | ||
29 | return rss << 12; /* assumes 4k pagesize */ | ||
30 | } | ||
31 | |||
32 | static void do_mmap(int fd, int extra_flags, int unmap) | ||
33 | { | ||
34 | int *p; | ||
35 | int flags = MAP_PRIVATE | MAP_POPULATE | extra_flags; | ||
36 | u64 before, after; | ||
37 | int ret; | ||
38 | |||
39 | before = read_rss(); | ||
40 | p = mmap(NULL, length, PROT_READ | PROT_WRITE, flags, fd, 0); | ||
41 | assert(p != MAP_FAILED || | ||
42 | !"mmap returned an unexpected error"); | ||
43 | after = read_rss(); | ||
44 | assert(llabs(after - before - length) < 0x40000 || | ||
45 | !"rss didn't grow as expected"); | ||
46 | if (!unmap) | ||
47 | return; | ||
48 | ret = munmap(p, length); | ||
49 | assert(!ret || !"munmap returned an unexpected error"); | ||
50 | after = read_rss(); | ||
51 | assert(llabs(after - before) < 0x40000 || | ||
52 | !"rss didn't shrink as expected"); | ||
53 | } | ||
54 | |||
55 | static int open_file(const char *path) | ||
56 | { | ||
57 | int fd, err; | ||
58 | |||
59 | unlink(path); | ||
60 | fd = open(path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL | ||
61 | | O_LARGEFILE | O_CLOEXEC, 0600); | ||
62 | assert(fd > 2); | ||
63 | unlink(path); | ||
64 | err = ftruncate(fd, length); | ||
65 | assert(!err); | ||
66 | return fd; | ||
67 | } | ||
68 | |||
69 | int main(void) | ||
70 | { | ||
71 | int hugefd, fd; | ||
72 | |||
73 | fd = open_file("/dev/shm/hugetlbhog"); | ||
74 | hugefd = open_file("/hugepages/hugetlbhog"); | ||
75 | |||
76 | system("echo 100 > /proc/sys/vm/nr_hugepages"); | ||
77 | do_mmap(-1, MAP_ANONYMOUS, 1); | ||
78 | do_mmap(fd, 0, 1); | ||
79 | do_mmap(-1, MAP_ANONYMOUS | MAP_HUGETLB, 1); | ||
80 | do_mmap(hugefd, 0, 1); | ||
81 | do_mmap(hugefd, MAP_HUGETLB, 1); | ||
82 | /* Leak the last one to test do_exit() */ | ||
83 | do_mmap(-1, MAP_ANONYMOUS | MAP_HUGETLB, 0); | ||
84 | printf("oll korrekt.\n"); | ||
85 | return 0; | ||
86 | } | ||
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 831adeb5fc55..9179ce8df485 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests | |||
@@ -75,16 +75,9 @@ else | |||
75 | echo "[PASS]" | 75 | echo "[PASS]" |
76 | fi | 76 | fi |
77 | 77 | ||
78 | echo "--------------------" | 78 | echo "NOTE: The above hugetlb tests provide minimal coverage. Use" |
79 | echo "running hugetlbfstest" | 79 | echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" |
80 | echo "--------------------" | 80 | echo " hugetlb regression testing." |
81 | ./hugetlbfstest | ||
82 | if [ $? -ne 0 ]; then | ||
83 | echo "[FAIL]" | ||
84 | exitcode=1 | ||
85 | else | ||
86 | echo "[PASS]" | ||
87 | fi | ||
88 | 81 | ||
89 | echo "--------------------" | 82 | echo "--------------------" |
90 | echo "running userfaultfd" | 83 | echo "running userfaultfd" |
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 76071b14cb93..2c7cca6f26a4 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c | |||
@@ -147,7 +147,8 @@ static void *locking_thread(void *arg) | |||
147 | if (sizeof(page_nr) > sizeof(rand_nr)) { | 147 | if (sizeof(page_nr) > sizeof(rand_nr)) { |
148 | if (random_r(&rand, &rand_nr)) | 148 | if (random_r(&rand, &rand_nr)) |
149 | fprintf(stderr, "random_r 2 error\n"), exit(1); | 149 | fprintf(stderr, "random_r 2 error\n"), exit(1); |
150 | page_nr |= ((unsigned long) rand_nr) << 32; | 150 | page_nr |= (((unsigned long) rand_nr) << 16) << |
151 | 16; | ||
151 | } | 152 | } |
152 | } else | 153 | } else |
153 | page_nr += 1; | 154 | page_nr += 1; |
@@ -290,7 +291,8 @@ static void *uffd_poll_thread(void *arg) | |||
290 | msg.event), exit(1); | 291 | msg.event), exit(1); |
291 | if (msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) | 292 | if (msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) |
292 | fprintf(stderr, "unexpected write fault\n"), exit(1); | 293 | fprintf(stderr, "unexpected write fault\n"), exit(1); |
293 | offset = (char *)msg.arg.pagefault.address - area_dst; | 294 | offset = (char *)(unsigned long)msg.arg.pagefault.address - |
295 | area_dst; | ||
294 | offset &= ~(page_size-1); | 296 | offset &= ~(page_size-1); |
295 | if (copy_page(offset)) | 297 | if (copy_page(offset)) |
296 | userfaults++; | 298 | userfaults++; |
@@ -327,7 +329,8 @@ static void *uffd_read_thread(void *arg) | |||
327 | if (bounces & BOUNCE_VERIFY && | 329 | if (bounces & BOUNCE_VERIFY && |
328 | msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) | 330 | msg.arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_WRITE) |
329 | fprintf(stderr, "unexpected write fault\n"), exit(1); | 331 | fprintf(stderr, "unexpected write fault\n"), exit(1); |
330 | offset = (char *)msg.arg.pagefault.address - area_dst; | 332 | offset = (char *)(unsigned long)msg.arg.pagefault.address - |
333 | area_dst; | ||
331 | offset &= ~(page_size-1); | 334 | offset &= ~(page_size-1); |
332 | if (copy_page(offset)) | 335 | if (copy_page(offset)) |
333 | (*this_cpu_userfaults)++; | 336 | (*this_cpu_userfaults)++; |