Re: [PATCH] mm/hugetlb: Fix pgtable lock on pmd sharing

From: Mike Kravetz
Date: Mon Jun 12 2023 - 17:45:08 EST


On 06/12/23 17:35, Peter Xu wrote:
> Hi, Mike!
>
> On Mon, Jun 12, 2023 at 01:44:18PM -0700, Mike Kravetz wrote:
> > Agree with this change. But, it does make one wonder if the pud_clear()
> > in huge_pmd_unshare is safe. Like here, we really should be holding the
> > higher level lock but are holding the PMD lock.
>
> The vma write lock? My memory tells me that you worked on the vma lock and
> one major reason was for that, but maybe I missed something?
>
> I did check again and all call sites should have that lock held, which
> looks fine here. One thing worth mention is pmd unshare should also always
> be gup-fast-safe because it never really releases the pgtable, unlike thp
> collapse.

Yes, Duh!

In the unshare case we KNOW what is mapped (the vma) via the PUD. So,
we certainly am synchronized with that access. I was just trying to
imagine some other situation where we may be walking the page table
without the vma lock held. However, you already took care of those call
sites.

Thanks!

You or Andrew can add,

Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>

--
Mike Kravetz