[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2b1b6d09-0188-23a3-6ac3-6e81446a10e4@huawei.com>
Date: Sat, 24 Sep 2022 21:11:48 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Mike Kravetz <mike.kravetz@...cle.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
CC: Muchun Song <songmuchun@...edance.com>,
David Hildenbrand <david@...hat.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Michal Hocko <mhocko@...e.com>, Peter Xu <peterx@...hat.com>,
Naoya Horiguchi <naoya.horiguchi@...ux.dev>,
"Aneesh Kumar K . V" <aneesh.kumar@...ux.vnet.ibm.com>,
Andrea Arcangeli <aarcange@...hat.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Davidlohr Bueso <dave@...olabs.net>,
Prakash Sangappa <prakash.sangappa@...cle.com>,
James Houghton <jthoughton@...gle.com>,
Mina Almasry <almasrymina@...gle.com>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Ray Fucillo <Ray.Fucillo@...ersystems.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2 6/9] hugetlb: add vma based lock for pmd sharing
On 2022/9/15 6:18, Mike Kravetz wrote:
> Allocate a new hugetlb_vma_lock structure and hang off vm_private_data
> for synchronization use by vmas that could be involved in pmd sharing.
> This data structure contains a rw semaphore that is the primary tool
> used for synchronization.
>
> This new structure is ref counted, so that it can exist when NOT attached
> to a vma. This is only helpful in resolving lock ordering issues where
> code may need to obtain the vma_lock while there are no guarantees the
> vma may go away. By obtaining a ref on the structure, it can be
> guaranteed that at least the rw semaphore will not go away.
>
> Only add infrastructure for the new lock here. Actual use will be added
> in subsequent patches.
>
> Signed-off-by: Mike Kravetz <mike.kravetz@...cle.com>
LGTM with some nits below. Thanks for your work, Mike.
Reviewed-by: Miaohe Lin <linmiaohe@...wei.com>
> -/* Reset counters to 0 and clear all HPAGE_RESV_* flags */
> -void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
> +void hugetlb_dup_vma_private(struct vm_area_struct *vma)
> {
> VM_BUG_ON_VMA(!is_vm_hugetlb_page(vma), vma);
> + /*
> + * Clear vm_private_data
> + * - For MAP_PRIVATE mappings, this is the reserve map which does
> + * not apply to children. Faults generated by the children are
> + * not guaranteed to succeed, even if read-only.
> + * - For shared mappings this is a per-vma semaphore that may be
> + * allocated in a subsequent call to hugetlb_vm_op_open.
> + */
> + vma->vm_private_data = (void *)0;
> if (!(vma->vm_flags & VM_MAYSHARE))
> - vma->vm_private_data = (void *)0;
> + return;
This if block can be deleted ? It doesn't do anything here.
> }
>
> /*
<snip>
> +static void hugetlb_vma_lock_free(struct vm_area_struct *vma)
> +{
> + /*
> + * Only present in sharable vmas. See comment in
> + * __unmap_hugepage_range_final about how VM_SHARED could
> + * be set without VM_MAYSHARE. As a result, we need to
> + * check if either is set in the free path.
> + */
> + if (!vma || !(vma->vm_flags & (VM_MAYSHARE | VM_SHARED)))
> + return;
> +
> + if (vma->vm_private_data) {
> + struct hugetlb_vma_lock *vma_lock = vma->vm_private_data;
> +
> + /*
> + * vma_lock structure may or not be released, but it
may or not be released?
Thanks,
Miaohe Lin
Powered by blists - more mailing lists