Re: [PATCH v3 2/3] mm/rmap: split try_to_migrate_hugetlb_one() out of try_to_migrate_one()
From: David Hildenbrand (Arm)
Date: Wed Dec 02 2026 - 10:40:19 EST
On 12/2/26 16:28, Garg, Shivank wrote:
> On Wed, 2026-12-02 at 16:18 +0100, David Hildenbrand (Arm) wrote:
>> On 12/2/26 15:17, Garg, Shivank wrote:
>>>
>>> Agreed. So I can directly use folio_page(folio, 0) or &folio->page.
>>>
>>> try_to_unmap_poisoned_hugetlb_one() covers both case with this
>>> VM_WARN_ON_ONCE(!pte_present(pteval));
>>> VM_WARN_ON_ONCE(pte_pfn(pteval) != folio_pfn(folio));
>>>
>>> yes, makes sense. I'll do this in V4.
>>> Thanks for suggestion.
>>
>> If there are ways to have two functions but have them reuse more code, that
>> would also work. But likely there is no easy way to get that done.
>
> I'm thinking of something like having:
>
> try_to_unmap_hugetlb_one(..., bool is_migration) {
> // all duplicate code
> if (migration) {
> // migration related stuff
> } else {
>
> }
> }
> then just call them like:
>
> try_to_migrate_hugetlb_one() {
> try_to_unmap_hugetlb_one(is_migration=true)
> }
>
> try_to_unmap_poisoned_hugetlb_one {
> try_to_unmap_hugetlb_one(is_migration=false)
> }
>
> This would remove the duplicate code and also easy.
Right, I was rather thinking of ways that don't require us passing booleans.
Maybe a function pointer to give us the new pte or sth like that ... not sure. :)
--
Cheers,
David