On 07.08.24 15:46, Usama Arif wrote:
This is an attempt to mitigate the issue of running out of memory when THP
is always enabled. During runtime whenever a THP is being faulted in
(__do_huge_pmd_anonymous_page) or collapsed by khugepaged
(collapse_huge_page), the THP is added to _deferred_list. Whenever memory
reclaim happens in linux, the kernel runs the deferred_split
shrinker which goes through the _deferred_list.
If the folio was partially mapped, the shrinker attempts to split it.
A new boolean is added to be able to distinguish between partially
mapped folios and others in the deferred_list at split time in
deferred_split_scan. Its needed as __folio_remove_rmap decrements
the folio mapcount elements, hence it won't be possible to distinguish
between partially mapped folios and others in deferred_split_scan
without the boolean.
Just so I get this right: Are you saying that we might now add fully
mapped folios to the deferred split queue and that's what you want to
distinguish?
If that's the case, then could we use a bit in folio->_flags_1 instead?
Further, I think you forgot to update at least one instance if a
list_empty(&folio->_deferred_list) check where we want to detect
"partially mapped". Please go over all and see what needs adjustments.
I would actually suggest to split decoupling of "_deferred_list" and
"partially mapped" into a separate preparation patch.
--
Cheers,
David / dhildenb