[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <eb6e18c0-533f-4e77-a56f-60ab8cacc369@redhat.com>
Date: Fri, 12 Sep 2025 09:31:04 +0200
From: David Hildenbrand <david@...hat.com>
To: jane.chu@...cle.com, harry.yoo@...cle.com, osalvador@...e.de,
liushixin2@...wei.com, muchun.song@...ux.dev, akpm@...ux-foundation.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/hugetlb: fix copy_hugetlb_page_range() to use
->pt_share_count
On 11.09.25 21:54, jane.chu@...cle.com wrote:
>
> On 9/9/2025 11:45 PM, David Hildenbrand wrote:
> [..]
>>> - /*
>>> - * 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.
>>> - */
>>> - if (page_count(virt_to_page(dst_pte)) > 1) {
>>> +#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING
>>> + /* If the pagetables are shared don't copy or take
>>> references. */
>>
>> Why remove so much of the original comment?
>
> Because, this part of checking has already advanced from the "dst_pte ==
> src_pte" to "page_count() > 1" to ->pt_share_count > 0, it seems cleaner
> to just keep an one liner comment.
> That said, if you feel the comments should be kept, I'd be happy to
> restore them with a bit revision.
Well, the comment explains why checking the pte pointers is insufficient
and why there is a corner case where the pointers differ but we still
want to unshare. :)
But yeah, I agree that reading the code it's clear: if dst is already
shared, just don't do anything.
I would probably rephrase the comment to something simpler like
"/* If the pagetables are shared, there is nothing to do. */
If you resend, please add a comment to the patch description like "While
at it, simplify the comment, the details are not actually relevant anymore".
--
Cheers
David / dhildenb
Powered by blists - more mailing lists