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: Thu, 9 Jan 2025 14:05:43 +0100 [thread overview]
Message-ID: <4e52d67c-e968-4cf6-9c9b-88646f0d3a23@redhat.com> (raw)
In-Reply-To: <20250109083527-e3c77b5f-14f5-467b-9cee-f71c75b2d654@linutronix.de>
>
> That is clear. The issue would be to figure which chunks are valid to
> unmap. If something critical like the executable file is unmapped,
> the process crashes. But see below.
Ah, now I see what you mean. Yes, also the stack etc. will be
problematic. So IIUC, you want to limit the munmap optimization only to
the manually mmap()ed parts.
>
>>> 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?
>
> First set the VMA name after mmap():
>
> for (i = 0; i < NR_CHUNKS_LOW; i++) {
> ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE,
> MAP_NORESERVE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>
> if (ptr[i] == MAP_FAILED) {
> if (validate_lower_address_hint())
> ksft_exit_fail_msg("mmap unexpectedly succeeded with hint\n");
> break;
> }
>
> validate_addr(ptr[i], 0);
> if (prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr[i], MAP_CHUNK_SIZE, "virtual_address_range"))
> ksft_exit_fail_msg("prctl(PR_SET_VMA_ANON_NAME) failed: %s\n", strerror(errno));
Likely this would prevent merging of VMAs.
With a 1 GiB chunk size, and NR_CHUNKS_LOW == 128TiB, you'd already
require 128k VMAs. The default limit is frequently 64k.
We could just scan the ptr / hptr array to see if this is a manual mmap
area or not. If this takes too long, one could sort the arrays by
address and perform a binary search.
Not the most efficient way of doing it, but maybe good enough for this test?
Alternatively, store the pointer in a xarray-like tree instead of two
arrays. Requires a bit more memory ... and we'd have to find a simple
implementation we could just reuse in this test. So maybe there is a
simpler way to get it done.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-01-09 13:05 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
2025-01-09 7:47 ` Thomas Weißschuh
2025-01-09 13:05 ` David Hildenbrand [this message]
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=4e52d67c-e968-4cf6-9c9b-88646f0d3a23@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