From: Lance Yang <lance.yang@linux.dev>
To: rppt@kernel.org
Cc: lance.yang@linux.dev, dave.hansen@intel.com,
xueyuan.chen21@gmail.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, x86@kernel.org,
catalin.marinas@arm.com, will@kernel.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
luto@kernel.org, peterz@infradead.org, hpa@zytor.com,
david@kernel.org, ljs@kernel.org, liam@infradead.org,
vbabka@kernel.org, surenb@google.com, mhocko@suse.com,
ziy@nvidia.com, baolin.wang@linux.alibaba.com, npache@redhat.com,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
yang@os.amperecomputing.com, jannh@google.com
Subject: Re: [RFC PATCH v2 1/3] mm/huge_memory: make persistent huge zero folio read-only
Date: Thu, 11 Jun 2026 18:35:12 +0800 [thread overview]
Message-ID: <20260611103512.46955-1-lance.yang@linux.dev> (raw)
In-Reply-To: <aipacpSZrO1DKooO@kernel.org>
On Thu, Jun 11, 2026 at 09:49:22AM +0300, Mike Rapoport wrote:
>Hi,
Hi,
>
>On Wed, Jun 10, 2026 at 11:20:22AM +0800, Lance Yang wrote:
>> Hi Dave,
>>
>> Thanks for taking the time to review.
>>
>> On Tue, Jun 09, 2026 at 12:33:36PM -0700, Dave Hansen wrote:
>> >On 6/9/26 07:37, Xueyuan Chen wrote:
>> >> +bool __weak arch_make_pages_readonly(struct page *page, int nr_pages)
>> >> +{
>> >> + return false;
>> >> +}
>> >
>> >This is a rather wonky function. It's going to cause all kinds of fun if
>> >it is used like this:
>> >
>> > arch_make_pages_readonly(syscall_table, 1);
>>
>> Ouch, yeah, it is ...
>
>We already have set_direct_map* APIs, why don't you add a new one there?
>set_direct_map_ro() for example.
Good point. I was trying to make this generic, but that's a bit too cute.
This is really a direct-map thing, so adding a set_direct_map_ro() helper
there makes more sense.
>
>> >It's also kinda weird to have it return a bool, and not check that bool
>> >at the single call site. Some things come to mind:
>> >
>> >1. This function needs commenting. It needs to say what it does, when
>> > architectures should override it and what their implementations
>> > should look like. It needs to be clear that this can't be used for
>> > anything really important. What should architectures do with alias
>> > mappings? Are they allowed to touch non-direct map aliases? Are they
>> > required to?
>>
>> Agreed. Needs a real comment ...
>>
>> Just meant as a best-effort direct/linear-map permission chang, nothing
>> stronger than that. I should spell out what happens, or does not happen,
>> to non-direct-map aliases, if anything, and make clear callers cannot
>> treat this as a hard guarantee :D
>
>It's not only about highmem, anything that changes the direct map might
>fail to allocate memory when splitting larger mappings.
Yes, exactly.
>
>> >2. The return type needs to be reconsidered. Is 'bool' even acceptable?
>> > Should it just be 'void' if callers can't do anything when it fails?
>>
>> Maybe ignoring it is OK now, but someone may need the return value later?
>>
>> >3. What should the naming be? "readonly" vs "ro". Should it have a
>> > "maybe" since it's kinda optional?
>>
>> Fair point. "make" may be overstating it a bit ...
>>
>> With a return value, arch_try_make_pages_readonly() sounds about right
>> to me. If we end up with void and pure best-effort semantics, maybe
>> arch_maybe_make_pages_readonly() fits better :)
>
>Realistically, I wouldn't expect 32-bit configs to enable
>PERSISTENT_HUGE_ZERO_FOLIO or even THP, so naming this function to reflect
>32-bit behaviour seems odd going forward.
Cool with that, if no one objects. No need to bake that into the name I
guess. int return plus a comment should be enough, just like
set_direct_map_*() family already does :)
>> >4. Should this new API be folio or page-based in the first place?
>>
>> For page vs folio, I was mostly following David's RFC v1 suggestion.
>>
>> Current caller is a folio, sure, but the page-range helper leaves room
>> for non-folio users later. Happy to add a simple folio wrapper if that
>> reads better ;)
>>
>> >5. Is mm/huge_memory.c the right place to define a generic mm function,
>> > even a stub?
>>
>> Ah, you're right! My bad, wrong place for a generic stub. Will move it
>> out for RFC v3.
>
>We have include/linux/set_memory.h for such function declarations and their
>stubs.
Yep, will move it there :)
Thanks, Lance
next prev parent reply other threads:[~2026-06-11 10:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 14:37 [RFC PATCH v2 0/3] make persistent huge zero folio read-only Xueyuan Chen
2026-06-09 14:37 ` [RFC PATCH v2 1/3] mm/huge_memory: " Xueyuan Chen
2026-06-09 19:33 ` Dave Hansen
2026-06-10 3:20 ` Lance Yang
2026-06-11 6:49 ` Mike Rapoport
2026-06-11 10:35 ` Lance Yang [this message]
2026-06-09 19:45 ` Andrew Morton
2026-06-10 2:15 ` Lance Yang
2026-06-11 11:28 ` David Hildenbrand (Arm)
2026-06-09 14:38 ` [RFC PATCH v2 2/3] arm64/mm: make pages read-only in the linear map Xueyuan Chen
2026-06-09 14:38 ` [RFC PATCH v2 3/3] x86/mm: make pages read-only in the direct map Xueyuan Chen
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=20260611103512.46955-1-lance.yang@linux.dev \
--to=lance.yang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=luto@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=npache@redhat.com \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xueyuan.chen21@gmail.com \
--cc=yang@os.amperecomputing.com \
--cc=ziy@nvidia.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