From: "Adrian Barnaś" <abarnas@google.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
David Hildenbrand <david@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
Christoph Lameter <cl@gentwo.org>,
Yang Shi <yang@os.amperecomputing.com>,
Brendan Jackman <jackmanb@google.com>,
Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [RFC PATCH 6/6] arm64: mm: support PMD page coalescing in the linear map
Date: Fri, 27 Nov 2026 07:45:59 +0000 [thread overview]
Message-ID: <awk1N98I7daqXHPC@google.com> (raw)
In-Reply-To: <awgbKPpwipkwkXPY@kernel.org>
On Thu, Nov 26, 2026 at 01:42:32PM +0200, Mike Rapoport wrote:
>Hi Adrian,
>
>On Mon, Nov 23, 2026 at 09:47:21AM +0000, Adrian Barnaś wrote:
>> On Mon, Jul 06, 2026 at 05:33:50PM +0300, Mike Rapoport wrote:
>> > > I
>> > > see that x86 has a lock that wraps entire process of updating attributes
>> > > (including spliting and collapsing pages):
>> > > ```
>> > > spin_lock(&cpa_lock);
>> > > ret = __change_page_attr(cpa, primary);
>> > > spin_unlock(&cpa_lock); ```
>> > > As I understand it makes it safe already.
>> > > However, on ARM64 there is a split lock (which works fine for spliting) but
>> > > for collapsing at least on my implementation it is not sufficient as
>> > > Ryan pointed out.
>> >
>> > I think the lock should be at set_memory level so that set_memory callers
>> > shouldn't care about the differences in arch implementations.
>
>For callers to stop caring about the differences in arch implementation we
>need this:
>
>https://lore.kernel.org/linux-mm/20261126-generic-set-memory-v0-1-v2-0-723f1e33c3d8@kernel.org/
>
>> I have recently got back to the topic, and I have one thing to clarify.
>>
>> Currently the collapsing mechanism that is backing execmem cache, following
>> execmem_restore_rox() description
>>
>> ```
>> * Restores read-only-execute permissions on a range [@ptr, @ptr + @size)
>> * after it was temporarily remapped as writable. Relies on architecture
>> * implementation of set_memory_rox() to restore mapping using large pages.
>>
>> ```
>> is driven entirely by the architecture code. It has drawbacks, that could be
>> addresed by passing some of the responsibility to memory owner,
>> execmem rox cache in this case.
>>
>> Arch code at no point is aware if the piece of memory it makes RW/RO, is
>> ment to be collapsed. Every permission change can cause entire block
>> to be collapsable so we need to try collapse on every run. We can probably
>> make RCU-like mechanism to batch those events but still there is a lot
>> of pointless runs just to find out we can't collapse or collapse of memory
>> block that already have split operation waiting for lock release.
>>
>> I was wondering if it would be acceptable to create a try_collapse operation
>> in set_memory api that would tell the arch code "I will probably not touch
>> this anymore for a while, you can collapse if you want". And call it after
>> predifined delay from last execmem_cache_restore_rox call.
>
>What do you mean by "last execmem_restore_rox"?
>How execmem would now that an execmem_restore_rox() is the last one?
>
That was a bit of a shorthand on my part. What I actually meant was
scheduling a delayed work and select a reasonable delay that will
oportunisticaly trigger after batch module load.
>> From execmem side it can be based on the same delayed work mechanism that
>> execmem_cache_free is using.
>>
>> I have a PoC locally but it is mostly vibecoded and I have already
>> discovered some bugs in it. But conceptualy it worked. After a batch load
>> of modules it collapsed all execmem cache blocks in both direct map and
>> vmalloc in a single run.
>>
>> Before I craft a proper patch set I want to ask if it is in any way
>> acceptable approach?
>
>I believe we could drive the collapse from the callers rather than from the
>architecture code.
>
>Other options could be to make the collapses wait until there is no other
>set_memory operations in flight or run a kthread that would collapse
>everything it could.
>
>But before optimizing collapse I think we should close the technical debt
>of having 7 different page table walkers implementing set_memory APIs.
>
>--
>Sincerely yours,
>Mike.
Thanks,
Adrian.
prev parent reply other threads:[~2026-11-27 7:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 13:01 [RFC PATCH 0/6] arm64: mm: Introducing ROX CACHE to ARM64 systems with bbml2 no abort Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 1/6] arm64: mm: explicitly declare module and ftrace execmem regions Adrian Barnaś
2026-06-11 13:36 ` Brendan Jackman
2026-06-11 13:01 ` [RFC PATCH 2/6] arm64: mm: allow huge vmap permission adjustments with bbml2_no_abort Adrian Barnaś
2026-06-18 14:21 ` Ryan Roberts
2026-06-24 13:54 ` Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 3/6] arm64: mm: fix restoring linear map permissions on execmem cache clean Adrian Barnaś
2026-06-11 13:54 ` Brendan Jackman
2026-06-12 7:17 ` Mike Rapoport
2026-06-17 15:18 ` Adrian Barnaś
2026-06-17 18:40 ` Mike Rapoport
2026-06-24 13:57 ` Adrian Barnaś
2026-07-06 11:35 ` Mike Rapoport
2026-07-06 12:47 ` Adrian Barnaś
2026-06-18 15:05 ` Ryan Roberts
2026-06-19 8:33 ` Ryan Roberts
2026-06-24 13:52 ` Adrian Barnaś
2026-06-11 13:01 ` [RFC PATCH 4/6] arm64: mm: add helper to fill execmem with trapping instructions Adrian Barnaś
2026-06-19 10:54 ` Ryan Roberts
2026-06-19 10:58 ` Mike Rapoport
2026-06-11 13:01 ` [RFC PATCH 5/6] arm64: execmem: enable EXECMEM_ROX_CACHE on supported CPUs Adrian Barnaś
2026-06-19 12:09 ` Ryan Roberts
2026-06-11 13:01 ` [RFC PATCH 6/6] arm64: mm: support PMD page coalescing in the linear map Adrian Barnaś
2026-06-19 13:40 ` Ryan Roberts
2026-06-24 14:32 ` Adrian Barnaś
2026-07-06 12:41 ` Adrian Barnaś
2026-07-06 14:33 ` Mike Rapoport
2026-11-23 9:47 ` Adrian Barnaś
2026-11-26 11:42 ` Mike Rapoport
2026-11-27 7:45 ` Adrian Barnaś [this message]
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=awk1N98I7daqXHPC@google.com \
--to=abarnas@google.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=jackmanb@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.com \
/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