[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0a70058f-e2fa-4f83-ace5-f58df589ac46@redhat.com>
Date: Thu, 24 Jul 2025 19:57:22 +0200
From: David Hildenbrand <david@...hat.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Dev Jain <dev.jain@....com>
Cc: akpm@...ux-foundation.org, ziy@...dia.com, baolin.wang@...ux.alibaba.com,
Liam.Howlett@...cle.com, npache@...hat.com, ryan.roberts@....com,
baohua@...nel.org, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/3] khugepaged: Optimize
__collapse_huge_page_copy_succeeded() by PTE batching
>> + if (folio_test_large(src)) {
>> + unsigned int max_nr_ptes = (end - address) >> PAGE_SHIFT;
>> +
>> + nr_ptes = folio_pte_batch(src, _pte, pteval, max_nr_ptes);
>> + } else {
>> release_pte_folio(src);
>> + }
>> +
>> /*
>> * ptl mostly unnecessary, but preempt has to
>> * be disabled to update the per-cpu stats
>> * inside folio_remove_rmap_pte().
>> */
>> spin_lock(ptl);
>> - ptep_clear(vma->vm_mm, address, _pte);
>> - folio_remove_rmap_pte(src, src_page, vma);
>> + clear_ptes(vma->vm_mm, address, _pte, nr_ptes);
>> + folio_remove_rmap_ptes(src, src_page, nr_ptes, vma);
>> spin_unlock(ptl);
>> - free_folio_and_swap_cache(src);
>> + free_swap_cache(src);
>> + folio_put_refs(src, nr_ptes);
>
> Hm one thing here though is the free_folio_and_swap_cache() does:
>
> free_swap_cache(folio);
> if (!is_huge_zero_folio(folio))
> folio_put(folio);
>
> Whereas here you unconditionally reduce the reference count. Might this
> cause issues with the shrinker version of the huge zero folio?
>
> Should this be:
>
> if (!is_huge_zero_folio(src))
> folio_put_refs(src, nr_ptes);
>
> Or do we otherwise avoid issues with this?
(resending my reply)
The huge zero folio is never PTE-mapped.
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists