selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()
authorDev Jain <dev.jain@arm.com>
Thu, 21 Mar 2024 10:35:22 +0000 (16:05 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 03:56:01 +0000 (20:56 -0700)
commit0104096498858346e3ac0668add1bf682461d4aa
tree89772645074aac8661d6d5bac0a37e10eb2fcbdb
parent42a346b41c5b17d2fd609279e0dd0a4257d8fba0
selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()

Currently, VA exhaustion is being checked by passing a hint to mmap() and
expecting it to fail.

While populating the lower VA space, mmap() fails because we have
exhausted the space.

Then, in validate_lower_address_hint(), because mmap() fails, we
confirm that we have indeed exhausted the space.  There is a circular
logic involved here.

Assume that there is a bug in mmap(), also assume that it exists
independent of whether you pass a hint address or not; that for some
reason it is not able to find a 1GB chunk.  My idea is to assert the
exhaustion against some other method.

This patch makes a stricter test by successful
write() calls from /proc/self/maps to a dump file, confirming that a free
chunk is indeed not available.

[dev.jain@arm.com: replace SZ_1GB with MAP_CHUNK_SIZE, tidy-up]
Link: https://lkml.kernel.org/r/20240325042653.867055-1-dev.jain@arm.com
Link: https://lkml.kernel.org/r/20240321103522.516097-1-dev.jain@arm.com
Signed-off-by: Dev Jain <dev.jain@arm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/virtual_address_range.c