Re: [RFC PATCH 1/3] mm: make persistent huge zero folio read-only

From: David Hildenbrand (Arm)

Date: Mon Jun 01 2026 - 11:52:49 EST


On 6/1/26 17:43, Lance Yang wrote:
>
>
> On 2026/6/1 21:49, David Hildenbrand (Arm) wrote:
>> On 5/27/26 17:55, Dave Hansen wrote:
>>> CONFIG_READONLY_HUGE_ZERO_FOLIO
>>>
>>> All of the #ifdeffery needs to die, IMNHO.
>>>
>>> This function is also a bad idea. There is nothing "huge zero" specific
>>> about it. It takes any old folio and tries to make it read only.
>>>
>>> Just make it:
>>>
>>>     bool __init arch_make_folio_readonly(struct folio *folio)
>>>
>>
>> I'm not sure whether we want a folio-based interface, though.
>>
>> This will likely be the only folio (that will actually have a "struct folio" in
>> the future) compound page we'll ever mark read-only ... whereby I'd guess we'd
>> want other non-folio pages to be read-only in the future (encryption keys etc,
>> maybe?).
>>
>> So I'd instead use a page-range based interface or sth like that.
>
> Just to check, did you mean something like:
>
> bool arch_make_pages_readonly(struct page *page, int nr_pages);
>
> ?
>
> So it can work on pages as well, not only folios :)

Yes, that would have been my first idea if we want to easily allow other reuse
in the future. Of course, we could add a folio wrapper that will likely mostly
be used by a single user ... :)

--
Cheers,

David