Re: [PATCH v3 1/9] mm: limit pagecache folio refcount when mapping pages

From: David Hildenbrand (Arm)

Date: Thu Nov 12 2026 - 10:53:51 EST


On 11/12/26 15:26, Pedro Falcato wrote:
> On Thu, Nov 12, 2026 at 03:16:00PM +0100, David Hildenbrand (Arm) wrote:
>> On 11/12/26 15:06, Pedro Falcato wrote:
>>>
>>> Alright.
>>>
>>>
>>> Yes. As far as I know, it's always fine, even under NMI. But definitely fine
>>> with IRQs disabled.
>>>
>>>
>>> I had the impression we had some stuff in-tree that isn't marked as GPL. But a quick
>>> grep shows that everything is either GPL or dual-licensed.
>>>
>>> In any case, yes, this will quite possibly break debug builds for people OOT.
>>> I think folio_get() might be a bit too ubiquitous to do this to.
>>
>> Thinking again, folio_get() should not be affected, it rightfully only checks
>> for a refcount underflow (when we exceed the limit + headroom). So only
>> try_get_page() is affected, which OOT very likely doesn't use.
>
> Aha, yes, you're right. I mixed up your folio_get() change. Would it make sense
> to VM_WARN_ON() on this as well, or does the <= 0 check cover us already?

<=0 is sufficient for folio_get(). There are valid cases where we can exceed the
limit into the rather large headroom (e.g., reaching the limit through page
table mappings, then performing harmless read/write that take bounded references
for a short time).

--
Cheers,

David