Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: do not require 64GB in set_memory_region_test

Unless the user sets overcommit_memory or has plenty of swap, the latest
changes to the testcase will result in ENOMEM failures for hosts with
less than 64GB RAM. As we do not use much of the allocated memory, we
can use MAP_NORESERVE to avoid this error.

Cc: Zenghui Yu <yuzenghui@huawei.com>
Cc: vkuznets@redhat.com
Cc: wanghaibin.wang@huawei.com
Cc: stable@vger.kernel.org
Fixes: 309505dd5685 ("KVM: selftests: Fix mapping length truncation in m{,un}map()")
Tested-by: Zenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/kvm/20210701160425.33666-1-borntraeger@de.ibm.com/
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

+2 -1
+2 -1
tools/testing/selftests/kvm/set_memory_region_test.c
··· 377 377 (max_mem_slots - 1), MEM_REGION_SIZE >> 10); 378 378 379 379 mem = mmap(NULL, (size_t)max_mem_slots * MEM_REGION_SIZE + alignment, 380 - PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 380 + PROT_READ | PROT_WRITE, 381 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); 381 382 TEST_ASSERT(mem != MAP_FAILED, "Failed to mmap() host"); 382 383 mem_aligned = (void *)(((size_t) mem + alignment - 1) & ~(alignment - 1)); 383 384