• Mike Kravetz's avatar
    hugetlb: add vma based lock for pmd sharing · 8d9bfb26
    Mike Kravetz authored
    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.
    
    [mike.kravetz@oracle.com: fix build issue for missing hugetlb_vma_lock_release]
      Link: https://lkml.kernel.org/r/YyNUtA1vRASOE4+M@monkey
    Link: https://lkml.kernel.org/r/20220914221810.95771-7-mike.kravetz@oracle.comSigned-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
    Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: James Houghton <jthoughton@google.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Mina Almasry <almasrymina@google.com>
    Cc: Muchun Song <songmuchun@bytedance.com>
    Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>
    Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Prakash Sangappa <prakash.sangappa@oracle.com>
    Cc: Sven Schnelle <svens@linux.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    8d9bfb26
hugetlb.c 204 KB