mbox series

[v2,0/5] mm: userfaultfd: refactor and add UFFDIO_CONTINUE_MODE_WP

Message ID 20230223005754.2700663-1-axelrasmussen@google.com
Headers show
Series mm: userfaultfd: refactor and add UFFDIO_CONTINUE_MODE_WP | expand

Message

Axel Rasmussen Feb. 23, 2023, 12:57 a.m. UTC
This series, currently based on 6.2, is divided into two parts:

- Commits 1-4 refactor userfaultfd ioctl code without behavior changes, with the
  main goal of improving consistency and reducing the number of function args.
- Commit 5 adds UFFDIO_CONTINUE_MODE_WP.

The refactors are sorted by increasing controversial-ness, the idea being we
could drop some of the refactors if they are deemed not worth it.

Changelog:
v1->v2: refactor before adding the new flag, to avoid perpetuating messiness

Axel Rasmussen (5):
  mm: userfaultfd: rename functions for clarity + consistency
  mm: userfaultfd: don't pass around both mm and vma
  mm: userfaultfd: combine 'mode' and 'wp_copy' arguments
  mm: userfaultfd: don't separate addr + len arguments
  mm: userfaultfd: add UFFDIO_CONTINUE_MODE_WP to install WP PTEs

 fs/userfaultfd.c                         | 121 +++++-------
 include/linux/hugetlb.h                  |  28 ++-
 include/linux/shmem_fs.h                 |   8 +-
 include/linux/userfaultfd_k.h            |  57 +++---
 include/uapi/linux/userfaultfd.h         |   7 +
 mm/hugetlb.c                             |  35 ++--
 mm/shmem.c                               |  13 +-
 mm/userfaultfd.c                         | 236 +++++++++++------------
 tools/testing/selftests/vm/userfaultfd.c |   4 +
 9 files changed, 245 insertions(+), 264 deletions(-)

--
2.39.2.637.g21b0678d19-goog

Comments

Axel Rasmussen Feb. 23, 2023, 7:03 p.m. UTC | #1
On Thu, Feb 23, 2023 at 10:51 AM Nadav Amit <namit@vmware.com> wrote:
>
>
>
> > On Feb 22, 2023, at 4:57 PM, Axel Rasmussen <axelrasmussen@google.com> wrote:
> >
> > Many userfaultfd ioctl functions take both a 'mode' and a 'wp_copy'
> > argument. In future commits we plan to plumb the flags through to more
> > places, so we'd be proliferating the very long argument list even
> > further.
> >
> > Let's take the time to simplify the argument list. Combine the two
> > arguments into one - and generalize, so when we add more flags in the
> > future, it doesn't imply more function arguments.
> >
> > Since the modes (copy, zeropage, continue) are mutually exclusive, store
> > them as an integer value (0, 1, 2) in the low bits. Place combine-able
> > flag bits in the high bits.
> >
> > Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
>
> Hi Axel,
>
> I sent a patch a long time ago called “userfaultfd: introduce uffd_flags”.
> For some reason it does not appear on lore, but you were a recipient.
>
> It was pretty similar, but one thing that I preferred in my version is
> that it defined a different type to avoid confusion. Since “flags” is
> a very generic name, perhaps you’d like to adapt this approach.

Oh! I must have missed it, or just forgot. I'll take a look and see
about making some improvements. I'll also be sure to credit you in the
commit message.

>