Re: [PATCH v5 02/10] hugetlb/userfaultfd: Forbid huge pmd sharing when uffd enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/12/21 12:47 PM, Axel Rasmussen wrote:
> On Fri, Feb 12, 2021 at 12:40 PM Peter Xu <peterx@xxxxxxxxxx> wrote:
>>
>> On Thu, Feb 11, 2021 at 04:19:55PM -0800, Mike Kravetz wrote:
>>> want_pmd_share() is currently just a check for CONFIG_ARCH_WANT_HUGE_PMD_SHARE.
>>> How about leaving that mostly as is, and adding the new vma checks to
>>> vma_shareable().  vma_shareable() would then be something like:
>>>
>>>       if (!(vma->vm_flags & VM_MAYSHARE))
>>>               return false;
>>> #ifdef CONFIG_USERFAULTFD
>>>       if (uffd_disable_huge_pmd_share(vma)
>>>               return false;
>>> #endif
>>> #ifdef /* XXX */
>>>       /* add other checks for things like uffd wp and soft dirty here */
>>> #endif /* XXX */
>>>
>>>       if (range_in_vma(vma, base, end)
>>>               return true;
>>>       return false;
>>>
>>> Of course, this would require we leave the call to vma_shareable() at the
>>> beginning of huge_pmd_share.  It also means that we are always making a
>>> function call into huge_pmd_share to determine if sharing is possible.
>>> That is not any different than today.  If we do not want to make that extra
>>> function call, then I would suggest putting all that code in want_pmd_share.
>>> It just seems that all the vma checks for sharing should be in one place
>>> if possible.
>>
>> I don't worry a lot on that since we've already got huge_pte_alloc() which
>> takes care of huge pmd sharing case, so I don't expect e.g. even most hugetlb
>> developers to use want_pmd_share() at all, because huge_pte_alloc() will be the
>> one that frequently got called.
>>
>> But yeah we can definitely put the check logic into huge_pmd_share() too.
>> Looking at above code it looks still worth a helper like want_pmd_share() or
>> with some other name.  Then... instead of making this complicated, how about I
>> mostly keep this patch but move want_pmd_share() call into huge_pmd_share()
>> instead?

When looking at this again, all I was suggesting was a single routine to
check for the possibility of pmd sharing.  That is what the version of
want_pmd_share in this patch does.

I have some patches for future optimizations that only take i_mmap_rwsem
in the fault path if sharing is possible.  This is before huge_pte_alloc.
want_pmd_share as defined in this patch would work for that.

Sorry for the noise.
-- 
Mike Kravetz




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux