• Axel Rasmussen's avatar
    mm: userfaultfd: rename functions for clarity + consistency · a734991c
    Axel Rasmussen authored
    Patch series "mm: userfaultfd: refactor and add UFFDIO_CONTINUE_MODE_WP",
    v5.
    
    - Commits 1-3 refactor userfaultfd ioctl code without behavior changes, with the
      main goal of improving consistency and reducing the number of function args.
    
    - Commit 4 adds UFFDIO_CONTINUE_MODE_WP.
    
    
    This patch (of 4):
    
    The basic problem is, over time we've added new userfaultfd ioctls, and
    we've refactored the code so functions which used to handle only one case
    are now re-used to deal with several cases.  While this happened, we
    didn't bother to rename the functions.
    
    Similarly, as we added new functions, we cargo-culted pieces of the
    now-inconsistent naming scheme, so those functions too ended up with names
    that don't make a lot of sense.
    
    A key point here is, "copy" in most userfaultfd code refers specifically
    to UFFDIO_COPY, where we allocate a new page and copy its contents from
    userspace.  There are many functions with "copy" in the name that don't
    actually do this (at least in some cases).
    
    So, rename things into a consistent scheme.  The high level idea is that
    the call stack for userfaultfd ioctls becomes:
    
    userfaultfd_ioctl
      -> userfaultfd_(particular ioctl)
        -> mfill_atomic_(particular kind of fill operation)
          -> mfill_atomic    /* loops over pages in range */
            -> mfill_atomic_pte    /* deals with single pages */
              -> mfill_atomic_pte_(particular kind of fill operation)
                -> mfill_atomic_install_pte
    
    There are of course some special cases (shmem, hugetlb), but this is the
    general structure which all function names now adhere to.
    
    Link: https://lkml.kernel.org/r/20230314221250.682452-1-axelrasmussen@google.com
    Link: https://lkml.kernel.org/r/20230314221250.682452-2-axelrasmussen@google.comSigned-off-by: default avatarAxel Rasmussen <axelrasmussen@google.com>
    Acked-by: default avatarPeter Xu <peterx@redhat.com>
    Acked-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: James Houghton <jthoughton@google.com>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Muchun Song <muchun.song@linux.dev>
    Cc: Nadav Amit <namit@vmware.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    a734991c
userfaultfd.c 56.7 KB