Skip to content

Commit a005145

Browse files
t-8chakpm00
authored andcommitted
selftests/mm: virtual_address_range: mmap() without PROT_WRITE
Patch series "selftests/mm: virtual_address_range: Reduce memory", v4. The selftest started failing since commit e93d252 ("x86/vdso: Split virtual clock pages into dedicated mapping") was merged. While debugging I stumbled upon some memory usage optimizations. With these test now runs on a VM with only 60MiB of memory. This patch (of 4): When mapping a larger chunk than physical memory is available with PROT_WRITE and overcommit is disabled, the mapping will fail. This will prevent the test from running on systems with less then ~1GiB of memory and triggering an inscrutinable test failure. As the mappings are never written to anyways, the flag can be removed. Link: https://lkml.kernel.org/r/20250114-virtual_address_range-tests-v4-0-6fd7269934a5@linutronix.de Link: https://lkml.kernel.org/r/20250114-virtual_address_range-tests-v4-1-6fd7269934a5@linutronix.de Fixes: 4e5ce33 ("selftests/vm: add a test for virtual address range mapping") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Dev Jain <dev.jain@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com> Cc: Shuah Khan (Samsung OSG) <shuah@kernel.org> Cc: kernel test robot <oliver.sang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 73519de commit a005145

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/mm/virtual_address_range.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int main(int argc, char *argv[])
166166
ksft_set_plan(1);
167167

168168
for (i = 0; i < NR_CHUNKS_LOW; i++) {
169-
ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE,
169+
ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ,
170170
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
171171

172172
if (ptr[i] == MAP_FAILED) {
@@ -186,7 +186,7 @@ int main(int argc, char *argv[])
186186

187187
for (i = 0; i < NR_CHUNKS_HIGH; i++) {
188188
hint = hint_addr();
189-
hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE,
189+
hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ,
190190
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
191191

192192
if (hptr[i] == MAP_FAILED)

0 commit comments

Comments
 (0)