From: Dev Jain <dev.jain@arm.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Shuah Khan" <shuah@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Ryan Roberts <ryan.roberts@arm.com>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH 1/3] selftests/mm: virtual_address_range: Fix error when CommitLimit < 1GiB
Date: Wed, 8 Jan 2025 11:46:19 +0530 [thread overview]
Message-ID: <5811cf74-d333-4653-ab64-0e981eda7745@arm.com> (raw)
In-Reply-To: <20250107-virtual_address_range-tests-v1-1-3834a2fb47fe@linutronix.de>
On 07/01/25 8:44 pm, Thomas Weißschuh wrote:
> If not enough physical memory is available the kernel may fail mmap();
> see __vm_enough_memory() and vm_commit_limit().
> In that case the logic in validate_complete_va_space() does not make
> sense and will even incorrectly fail.
> Instead skip the test if no mmap() succeeded.
>
> Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> ---
> The logic in __vm_enough_memory() seems weird.
> It describes itself as "Check that a process has enough memory to
> allocate a new virtual mapping", however it never checks the current
> memory usage of the process.
> So it only disallows large mappings. But many small mappings taking the
> same amount of memory are allowed; and then even automatically merged
> into one big mapping.
> ---
> tools/testing/selftests/mm/virtual_address_range.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c
> index 2a2b69e91950a37999f606847c9c8328d79890c2..d7bf8094d8bcd4bc96e2db4dc3fcb41968def859 100644
> --- a/tools/testing/selftests/mm/virtual_address_range.c
> +++ b/tools/testing/selftests/mm/virtual_address_range.c
> @@ -178,6 +178,12 @@ int main(int argc, char *argv[])
> validate_addr(ptr[i], 0);
> }
> lchunks = i;
> +
> + if (!lchunks) {
> + ksft_test_result_skip("Not enough memory for a single chunk\n");
> + ksft_finished();
> + }
> +
> hptr = (char **) calloc(NR_CHUNKS_HIGH, sizeof(char *));
> if (hptr == NULL) {
> ksft_test_result_skip("Memory constraint not fulfilled\n");
>
I do not know about __vm_enough_memory(), but I am going by your description:
You say that the kernel may fail mmap() when enough physical memory is not
there, but it may happen that we have already done 100 mmap()'s, and then
the kernel fails mmap(), so if (!lchunks) won't be able to handle this case.
Basically, lchunks == 0 is not a complete indicator of kernel failing mmap().
The basic assumption of the test is that any process should be able to exhaust
its virtual address space, and running the test under memory pressure and the
kernel violating this behaviour defeats the point of the test I think?
next prev parent reply other threads:[~2025-01-08 6:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 15:14 [PATCH 0/3] selftests/mm: virtual_address_range: Two bugfixes and a cleanup Thomas Weißschuh
2025-01-07 15:14 ` [PATCH 1/3] selftests/mm: virtual_address_range: Fix error when CommitLimit < 1GiB Thomas Weißschuh
2025-01-08 6:16 ` Dev Jain [this message]
2025-01-08 8:05 ` Thomas Weißschuh
2025-01-08 13:36 ` David Hildenbrand
2025-01-08 16:13 ` Thomas Weißschuh
2025-01-08 16:46 ` David Hildenbrand
2025-01-09 7:47 ` Thomas Weißschuh
2025-01-09 13:05 ` David Hildenbrand
2025-01-09 13:19 ` David Hildenbrand
2025-01-09 13:38 ` Thomas Weißschuh
2025-01-09 5:40 ` Dev Jain
2025-01-07 15:14 ` [PATCH 2/3] selftests/mm: virtual_address_range: Avoid reading VVAR mappings Thomas Weißschuh
2025-01-07 15:14 ` [PATCH 3/3] selftests/mm: virtual_address_range: Dump to /dev/null Thomas Weißschuh
2025-01-08 6:09 ` Dev Jain
2025-01-08 7:38 ` Thomas Weißschuh
2025-01-08 13:30 ` David Hildenbrand
2025-01-09 5:32 ` Dev Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5811cf74-d333-4653-ab64-0e981eda7745@arm.com \
--to=dev.jain@arm.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox