diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-08 21:17:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-08 21:17:56 -0400 |
commit | bf5f89463f5b3109a72ed13ca62b57e90213387d (patch) | |
tree | f9f288a341dd86efa996f7a08fb425eae34eb446 /tools | |
parent | 2d3e4866dea96b0506395b47bfefb234f2088dac (diff) | |
parent | 4d2b5bcab53f1c76a86279339561c9a36109a93b (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
- the rest of MM
- various misc things
- procfs updates
- lib/ updates
- checkpatch updates
- kdump/kexec updates
- add kvmalloc helpers, use them
- time helper updates for Y2038 issues. We're almost ready to remove
current_fs_time() but that awaits a btrfs merge.
- add tracepoints to DAX
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (114 commits)
drivers/staging/ccree/ssi_hash.c: fix build with gcc-4.4.4
selftests/vm: add a test for virtual address range mapping
dax: add tracepoint to dax_insert_mapping()
dax: add tracepoint to dax_writeback_one()
dax: add tracepoints to dax_writeback_mapping_range()
dax: add tracepoints to dax_load_hole()
dax: add tracepoints to dax_pfn_mkwrite()
dax: add tracepoints to dax_iomap_pte_fault()
mtd: nand: nandsim: convert to memalloc_noreclaim_*()
treewide: convert PF_MEMALLOC manipulations to new helpers
mm: introduce memalloc_noreclaim_{save,restore}
mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC
mm/huge_memory.c: deposit a pgtable for DAX PMD faults when required
mm/huge_memory.c: use zap_deposited_table() more
time: delete CURRENT_TIME_SEC and CURRENT_TIME
gfs2: replace CURRENT_TIME with current_time
apparmorfs: replace CURRENT_TIME with current_time()
lustre: replace CURRENT_TIME macro
fs: ubifs: replace CURRENT_TIME_SEC with current_time
fs: ufs: use ktime_get_real_ts64() for birthtime
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/vm/Makefile | 1 | ||||
-rwxr-xr-x | tools/testing/selftests/vm/run_vmtests | 11 | ||||
-rw-r--r-- | tools/testing/selftests/vm/virtual_address_range.c | 122 |
3 files changed, 134 insertions, 0 deletions
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index dba889004ea1..cbb29e41ef2b 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -16,6 +16,7 @@ TEST_GEN_FILES += thuge-gen | |||
16 | TEST_GEN_FILES += transhuge-stress | 16 | TEST_GEN_FILES += transhuge-stress |
17 | TEST_GEN_FILES += userfaultfd | 17 | TEST_GEN_FILES += userfaultfd |
18 | TEST_GEN_FILES += mlock-random-test | 18 | TEST_GEN_FILES += mlock-random-test |
19 | TEST_GEN_FILES += virtual_address_range | ||
19 | 20 | ||
20 | TEST_PROGS := run_vmtests | 21 | TEST_PROGS := run_vmtests |
21 | 22 | ||
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 3214a6456d13..0640923ded7e 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests | |||
@@ -165,4 +165,15 @@ else | |||
165 | echo "[PASS]" | 165 | echo "[PASS]" |
166 | fi | 166 | fi |
167 | 167 | ||
168 | echo "-----------------------------" | ||
169 | echo "running virtual_address_range" | ||
170 | echo "-----------------------------" | ||
171 | ./virtual_address_range | ||
172 | if [ $? -ne 0 ]; then | ||
173 | echo "[FAIL]" | ||
174 | exitcode=1 | ||
175 | else | ||
176 | echo "[PASS]" | ||
177 | fi | ||
178 | |||
168 | exit $exitcode | 179 | exit $exitcode |
diff --git a/tools/testing/selftests/vm/virtual_address_range.c b/tools/testing/selftests/vm/virtual_address_range.c new file mode 100644 index 000000000000..3b02aa6eb9da --- /dev/null +++ b/tools/testing/selftests/vm/virtual_address_range.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * Copyright 2017, Anshuman Khandual, IBM Corp. | ||
3 | * Licensed under GPLv2. | ||
4 | * | ||
5 | * Works on architectures which support 128TB virtual | ||
6 | * address range and beyond. | ||
7 | */ | ||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <string.h> | ||
11 | #include <unistd.h> | ||
12 | #include <errno.h> | ||
13 | #include <numaif.h> | ||
14 | #include <sys/mman.h> | ||
15 | #include <sys/time.h> | ||
16 | |||
17 | /* | ||
18 | * Maximum address range mapped with a single mmap() | ||
19 | * call is little bit more than 16GB. Hence 16GB is | ||
20 | * chosen as the single chunk size for address space | ||
21 | * mapping. | ||
22 | */ | ||
23 | #define MAP_CHUNK_SIZE 17179869184UL /* 16GB */ | ||
24 | |||
25 | /* | ||
26 | * Address space till 128TB is mapped without any hint | ||
27 | * and is enabled by default. Address space beyond 128TB | ||
28 | * till 512TB is obtained by passing hint address as the | ||
29 | * first argument into mmap() system call. | ||
30 | * | ||
31 | * The process heap address space is divided into two | ||
32 | * different areas one below 128TB and one above 128TB | ||
33 | * till it reaches 512TB. One with size 128TB and the | ||
34 | * other being 384TB. | ||
35 | */ | ||
36 | #define NR_CHUNKS_128TB 8192UL /* Number of 16GB chunks for 128TB */ | ||
37 | #define NR_CHUNKS_384TB 24576UL /* Number of 16GB chunks for 384TB */ | ||
38 | |||
39 | #define ADDR_MARK_128TB (1UL << 47) /* First address beyond 128TB */ | ||
40 | |||
41 | static char *hind_addr(void) | ||
42 | { | ||
43 | int bits = 48 + rand() % 15; | ||
44 | |||
45 | return (char *) (1UL << bits); | ||
46 | } | ||
47 | |||
48 | static int validate_addr(char *ptr, int high_addr) | ||
49 | { | ||
50 | unsigned long addr = (unsigned long) ptr; | ||
51 | |||
52 | if (high_addr) { | ||
53 | if (addr < ADDR_MARK_128TB) { | ||
54 | printf("Bad address %lx\n", addr); | ||
55 | return 1; | ||
56 | } | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | if (addr > ADDR_MARK_128TB) { | ||
61 | printf("Bad address %lx\n", addr); | ||
62 | return 1; | ||
63 | } | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int validate_lower_address_hint(void) | ||
68 | { | ||
69 | char *ptr; | ||
70 | |||
71 | ptr = mmap((void *) (1UL << 45), MAP_CHUNK_SIZE, PROT_READ | | ||
72 | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
73 | |||
74 | if (ptr == MAP_FAILED) | ||
75 | return 0; | ||
76 | |||
77 | return 1; | ||
78 | } | ||
79 | |||
80 | int main(int argc, char *argv[]) | ||
81 | { | ||
82 | char *ptr[NR_CHUNKS_128TB]; | ||
83 | char *hptr[NR_CHUNKS_384TB]; | ||
84 | char *hint; | ||
85 | unsigned long i, lchunks, hchunks; | ||
86 | |||
87 | for (i = 0; i < NR_CHUNKS_128TB; i++) { | ||
88 | ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, | ||
89 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
90 | |||
91 | if (ptr[i] == MAP_FAILED) { | ||
92 | if (validate_lower_address_hint()) | ||
93 | return 1; | ||
94 | break; | ||
95 | } | ||
96 | |||
97 | if (validate_addr(ptr[i], 0)) | ||
98 | return 1; | ||
99 | } | ||
100 | lchunks = i; | ||
101 | |||
102 | for (i = 0; i < NR_CHUNKS_384TB; i++) { | ||
103 | hint = hind_addr(); | ||
104 | hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, | ||
105 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
106 | |||
107 | if (hptr[i] == MAP_FAILED) | ||
108 | break; | ||
109 | |||
110 | if (validate_addr(hptr[i], 1)) | ||
111 | return 1; | ||
112 | } | ||
113 | hchunks = i; | ||
114 | |||
115 | for (i = 0; i < lchunks; i++) | ||
116 | munmap(ptr[i], MAP_CHUNK_SIZE); | ||
117 | |||
118 | for (i = 0; i < hchunks; i++) | ||
119 | munmap(hptr[i], MAP_CHUNK_SIZE); | ||
120 | |||
121 | return 0; | ||
122 | } | ||