Re: [PATCH v10 15/41] KVM: guest_memfd: Handle lru_add fbatch refcounts during conversion safety check
From: Ackerley Tng
Date: Sun Aug 16 2026 - 19:02:39 EST
Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> writes:
>
> [...snip...]
>
>> +static bool __folio_safe_for_conversion(struct folio *folio,
>> + enum lru_cache_drained *drained)
>> +{
>> + const int filemap_get_folios_refcount = 1;
>> +
>
> Nit:
> After adding the helper, the use of filemap_get_folios_refcount seems
> less obvious. It introduces unnecessary tight coupling with the caller,
> though it has only one caller currently.
>
> Is it better to pass the value as extra_refs, similar to what
> lru_cache_drain_for_folio() does?
>
>
David also suggested [1] something similar, please see
https://lore.kernel.org/all/4c638fc5-5a74-43d0-b5bf-d7ef893cb994@xxxxxxxxxx/,
Please add on to that thread if you disagree with the suggestions!
>> + if (folio_maybe_dma_pinned(folio) || folio_mapped(folio))
>> + return false;
>> +
>> + lru_cache_drain_for_folio(folio, filemap_get_folios_refcount,
>> + drained);
>> +
>> + return folio_ref_count(folio) ==
>> + folio_nr_pages(folio) + filemap_get_folios_refcount;
>> +}
>> +
>>
>> [...snip...]
>>