• Lokesh Gidra's avatar
    userfaultfd: move userfaultfd_ctx struct to header file · f91e6b41
    Lokesh Gidra authored
    Patch series "per-vma locks in userfaultfd", v7.
    
    Performing userfaultfd operations (like copy/move etc.) in critical
    section of mmap_lock (read-mode) causes significant contention on the lock
    when operations requiring the lock in write-mode are taking place
    concurrently.  We can use per-vma locks instead to significantly reduce
    the contention issue.
    
    Android runtime's Garbage Collector uses userfaultfd for concurrent
    compaction.  mmap-lock contention during compaction potentially causes
    jittery experience for the user.  During one such reproducible scenario,
    we observed the following improvements with this patch-set:
    
    - Wall clock time of compaction phase came down from ~3s to <500ms
    - Uninterruptible sleep time (across all threads in the process) was
      ~10ms (none in mmap_lock) during compaction, instead of >20s
    
    
    This patch (of 4):
    
    Move the struct to userfaultfd_k.h to be accessible from mm/userfaultfd.c.
    There are no other changes in the struct.
    
    This is required to prepare for using per-vma locks in userfaultfd
    operations.
    
    Link: https://lkml.kernel.org/r/20240215182756.3448972-1-lokeshgidra@google.com
    Link: https://lkml.kernel.org/r/20240215182756.3448972-2-lokeshgidra@google.com
    
    Signed-off-by: default avatarLokesh Gidra <lokeshgidra@google.com>
    Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
    Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Brian Geffon <bgeffon@google.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Jann Horn <jannh@google.com>
    Cc: Kalesh Singh <kaleshsingh@google.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Nicolas Geoffray <ngeoffray@google.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Ryan Roberts <ryan.roberts@arm.com>
    Cc: Suren Baghdasaryan <surenb@google.com>
    Cc: Tim Murray <timmurray@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    f91e6b41
userfaultfd.c 58.6 KB