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

From: Lance Yang <[email-masked]>
Date: Mon, 1 Jun 2026 23:43:56 +0800

On 2026/6/1 21:49, David Hildenbrand (Arm) wrote:
> On 5/27/26 17:55, Dave Hansen wrote:
>> On 5/26/26 20:56, Xueyuan chen wrote:> +#ifdef
>> CONFIG_READONLY_HUGE_ZERO_FOLIO
>>> +bool __init arch_make_huge_zero_folio_readonly(struct folio *folio);
>>> +#endif
>>
>> 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 :)