Re: [PATCH v6 3/3] mm: implement page refcount locking via dedicated bit

From: David Hildenbrand (Arm)

Date: Fri Sep 25 2026 - 03:15:48 EST


On 9/25/26 04:44, Zi Yan wrote:
> On Thu Sep 24, 2026 at 4:06 PM EDT, Linus Torvalds wrote:
>> On Thu, 24 Sept 2026 at 11:52, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>>>
>>> There needs to be a common page freeing function that dipatches stuff.
>>
>> I think this all needs to be entirely generic to all pages. Agreed.
>> Everybody needs to do it right.
>
> It assumes all callers of page_ref_dec_and_test() are free page
> functions, but there are two exceptions:

Right, we'll have to sort these out. Which is the right thing to do either way :)

>
> 1. compaction_free() uses folio_put_testzero(), which calls
> page_ref_dec_and_test() to put not used migration dst page back to
> isolated freelist instead of freeing them.
>
> 2. virtio_mem_fake_offline_going_offline() drops the last reference of
> fake-offline pages, so that they can be offline.

I had a patch for that, where we keep the refcount untouched:

https://lore.kernel.org/linux-mm/20250520164216.866543-2-david@xxxxxxxxxx/

Long-term PG_offline pages will not have a refcount at all, and just have a
frozen refcount. That's the right solution long-term: allocate+free them as
frozen in virtio-mem. Needs some more work, though :)

--
Cheers,

David