On Fri, Nov 08, 2024 at 04:20:30PM +0000, Fuad Tabba wrote: > Some folios, such as hugetlb folios and zone device folios, > require special handling when the folio's reference count reaches > 0, before being freed. Moreover, guest_memfd folios will likely > require special handling to notify it once a folio's reference > count reaches 0, to facilitate shared to private folio conversion > [*]. Currently, each usecase has a dedicated callback when the > folio refcount reaches 0 to that effect. Adding yet more > callbacks is not ideal. Honestly, I question this thesis. How complex would it be to have 'yet more callbacks'? Is the challenge really that the mm can't detect when guestmemfd is the owner of the page because the page will be ZONE_NORMAL? So the point of this is really to allow ZONE_NORMAL pages to have a per-allocator callback? But this is also why I suggested to shift them to ZONE_DEVICE for guestmemfd, because then you get these things for free from the pgmap. (this is not a disagreement this is a valid solution, but a request you explain much more about what it is you actually need and compare it with the other existing options) Jason