Re: [v1 resend 03/12] mm/thp: zone_device awareness in THP handling code

From: Balbir Singh
Date: Tue Jul 08 2025 - 03:41:06 EST


On 7/7/25 16:09, Alistair Popple wrote:
> On Sat, Jul 05, 2025 at 10:14:18AM +1000, Balbir Singh wrote:
>> On 7/4/25 21:10, Mika Penttilä wrote:
>>>> /* Racy check whether the huge page can be split */
>>>> @@ -3543,6 +3594,10 @@ static int __split_unmapped_folio(struct folio *folio, int new_order,
>>>> ((mapping || swap_cache) ?
>>>> folio_nr_pages(release) : 0));
>>>>
>>>> + if (folio_is_device_private(release))
>>>> + percpu_ref_get_many(&release->pgmap->ref,
>>>> + (1 << new_order) - 1);
>>>
>>> pgmap refcount should not be modified here, count should remain the same after the split also
>
> Agreed.
>
>>>
>>>
>>
>> Good point, let me revisit the accounting
>
> Yes, hopefully we can just delete it.
>
>> For this patch series, the tests did not catch it since new ref's evaluate to 0
>
> You may not notice bad accounting here unless you unload the kernel module,
> which can hang during memunmap() pages waiting for the refcount to go to zero.
>

The tests do have an eviction test, which tests that all pages can indeed be evicted
and I do unload/reload the driver

Balbir Singh