• Peter Xu's avatar
    mm/gup: rename "nonblocking" to "locked" where proper · 4f6da934
    Peter Xu authored
    Patch series "mm: Page fault enhancements", v6.
    
    This series contains cleanups and enhancements to current page fault
    logic.  The whole idea comes from the discussion between Andrea and Linus
    on the bug reported by syzbot here:
    
      https://lkml.org/lkml/2017/11/2/833
    
    Basically it does two things:
    
      (a) Allows the page fault logic to be more interactive on not only
          SIGKILL, but also the rest of userspace signals, and,
    
      (b) Allows the page fault retry (VM_FAULT_RETRY) to happen for more
          than once.
    
    For (a): with the changes we should be able to react faster when page
    faults are working in parallel with userspace signals like SIGSTOP and
    SIGCONT (and more), and with that we can remove the buggy part in
    userfaultfd and benefit the whole page fault mechanism on faster signal
    processing to reach the userspace.
    
    For (b), we should be able to allow the page fault handler to loop for
    even more than twice.  Some context: for now since we have
    FAULT_FLAG_ALLOW_RETRY we can allow to retry the page fault once with the
    same interrupt context, however never more than twice.  This can be not
    only a potential cleanup to remove this assumption since AFAIU the code
    itself doesn't really have this twice-only limitation (though that should
    be a protective approach in the past), at the same time it'll greatly
    simplify future works like userfaultfd write-protect where it's possible
    to retry for more than twice (please have a look at [1] below for a
    possible user that might require the page fault to be handled for a third
    time; if we can remove the retry limitation we can simply drop that patch
    and those complexity).
    
    This patch (of 16):
    
    There's plenty of places around __get_user_pages() that has a parameter
    "nonblocking" which does not really mean that "it won't block" (because it
    can really block) but instead it shows whether the mmap_sem is released by
    up_read() during the page fault handling mostly when VM_FAULT_RETRY is
    returned.
    
    We have the correct naming in e.g.  get_user_pages_locked() or
    get_user_pages_remote() as "locked", however there're still many places
    that are using the "nonblocking" as name.
    
    Renaming the places to "locked" where proper to better suite the
    functionality of the variable.  While at it, fixing up some of the
    comments accordingly.
    Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Tested-by: default avatarBrian Geffon <bgeffon@google.com>
    Reviewed-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
    Reviewed-by: default avatarJerome Glisse <jglisse@redhat.com>
    Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Martin Cracauer <cracauer@cons.org>
    Cc: "Kirill A . Shutemov" <kirill@shutemov.name>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
    Cc: Bobby Powers <bobbypowers@gmail.com>
    Cc: Maya Gokhale <gokhale2@llnl.gov>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Marty McFadden <mcfadden8@llnl.gov>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
    Cc: Pavel Emelyanov <xemul@openvz.org>
    Link: http://lkml.kernel.org/r/20200220155353.8676-2-peterx@redhat.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    4f6da934
gup.c 80.9 KB