Re: [PATCH v2 10/10] mm/hugetlb: Document why page_vma_mapped_walk() is safe to walk

John Hubbard
2022-12-08T21:55:01Z

On 12/8/22 13:05, Peter Xu wrote:
>>> + /*
>>> + * NOTE: we don't need explicit lock here to walk the
>>> + * hugetlb pgtable because either (1) potential callers of
>>> + * hugetlb pvmw currently holds i_mmap_rwsem, or (2) the
>>> + * caller will not walk a hugetlb vma (e.g. ksm or uprobe).
>>> + * When one day this rule breaks, one will get a warning
>>> + * in hugetlb_walk(), and then we'll figure out what to do.
>>> + */
>>
>> Confused. Is this documentation actually intended to refer to hugetlb_walk()
>> itself, or just this call site? If the former, then let's move it over
>> to be right before hugetlb_walk().
>
> It is for this specific code path not hugetlb_walk().
>
> The "holds i_mmap_rwsem" here is a true statement (not requirement) because
> PVMW rmap walkers always have that. That satisfies with hugetlb_walk()
> requirements already even without holding the vma lock.
>

It's really hard to understand. Do you have a few extra words to explain it?
I can help with actual comment wording perhaps, but I am still a bit in
the dark as to the actual meaning. :)

thanks,
--
John Hubbard
NVIDIA