From: David Hildenbrand <david@redhat.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Dev Jain <dev.jain@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [PATCH 1/3] selftests/mm: virtual_address_range: Fix error when CommitLimit < 1GiB
Date: Wed, 8 Jan 2025 17:46:37 +0100 [thread overview]
Message-ID: <618798d5-71b2-43d6-8f5c-78d911c5dd43@redhat.com> (raw)
In-Reply-To: <20250108165052-c03470bd-6ff7-44c9-87b9-9145456bdea8@linutronix.de>
On 08.01.25 17:13, Thomas Weißschuh wrote:
> On Wed, Jan 08, 2025 at 02:36:57PM +0100, David Hildenbrand wrote:
>> On 08.01.25 09:05, Thomas Weißschuh wrote:
>>> On Wed, Jan 08, 2025 at 11:46:19AM +0530, Dev Jain wrote:
>>>>
>>>> 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
>>
>> CC stable on tests is ... odd.
>
> I thought it was fairly common, but it isn't.
> Will drop it.
As it's not really a "kernel BUG", it's rather uncommon.
>>
>> Note that with MAP_NORESRVE, most setups we care about will allow mapping as
>> much as you want, but on access OOM will fire.
>
> Thanks for the hint.
>
>> So one could require that /proc/sys/vm/overcommit_memory is setup properly
>> and use MAP_NORESRVE.
>
> Isn't the check for lchunks == 0 essentially exactly this?
I assume paired with MAP_NORESERVE?
Maybe, but it could be better to have something that says "if
overcommit_memory is not setup properly I will SKIP this test", but
otherwise I expect this to work and will FAIL if it doesn't".
Or would you expect to run into lchunks == 0 even if overcommit_memory
is setup properly and MAP_NORESERVE is used? (very very low memory that
we cannot even create all the VMAs?)
>
>> Reading from anonymous memory will populate the shared zeropage. To mitigate
>> OOM from "too many page tables", one could simply unmap the pieces as they
>> are verified (or MAP_FIXED over them, to free page tables).
>
> The code has to figure out if a verified region was created by mmap(),
> otherwise an munmap() could crash the process.
> As the entries from /proc/self/maps may have been merged and (I assume)
Yes, and partial unmap (in chunk granularity?) would split them again.
> the ordering of mappings is not guaranteed, some bespoke logic to establish
> the link will be needed.
My thinking was that you simply process one /proc/self/maps entry in
some chunks. After processing a chunk, you munmap() it.
So you would process + munmap in chunks.
>
> Is it fine to rely on CONFIG_ANON_VMA_NAME?
> That would make it much easier to implement.
Can you elaborate how you would do it?
>
> Using MAP_NORESERVE and eager munmap()s, the testcase works nicely even
> in very low physical memory conditions.
Cool.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-01-08 16:46 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
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 [this message]
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=618798d5-71b2-43d6-8f5c-78d911c5dd43@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dev.jain@arm.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