Re: [PATCH v2] mm/hugetlb: fix copy_hugetlb_page_range() to use ->pt_share_count

David Hildenbrand
2025-09-12T07:32:32Z

On 11.09.25 21:58, jane.chu@oracle.com wrote:
>
>
> On 9/11/2025 1:17 AM, David Hildenbrand wrote:
> [..]
>>>
>>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>>> index 753f99b4c718..8ca5b4f7805f 100644
>>> --- a/mm/hugetlb.c
>>> +++ b/mm/hugetlb.c
>>> @@ -5594,18 +5594,13 @@ int copy_hugetlb_page_range(struct mm_struct
>>> *dst, struct mm_struct *src,
>>>               break;
>>>           }
>>> -        /*
>>> -         * If the pagetables are shared don't copy or take references.
>>> -         *
>>> -         * dst_pte == src_pte is the common case of src/dest sharing.
>>> -         * However, src could have 'unshared' and dst shares with
>>> -         * another vma. So page_count of ptep page is checked instead
>>> -         * to reliably determine whether pte is shared.
>>> -         */
>>
>> I think you ignored my question to v1 regarding the change of comment.
>>
>
> Sorry David, didn't mean disrespect, I missed your earlier comments.

No worries. Replied there about possibly simplifying the comment further.

BTW, I think the code would be even clearer if we would have

ptdesc_pmd_is_shared()

that is simply a wrapper around the ptdesc_pmd_pts_count() check.

--
Cheers

David / dhildenb