Re: [PATCH v2 1/5] userfaultfd: introduce uffd_flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Jul 23, 2022, at 2:12 AM, Mike Rapoport <rppt@xxxxxxxxxxxxx> wrote:
> 
> On Mon, Jul 18, 2022 at 04:47:44AM -0700, Nadav Amit wrote:
>> From: Nadav Amit <namit@xxxxxxxxxx>
>> 
>> As the next patches are going to introduce more information that needs
>> to be propagated regarding handled user requests, introduce uffd_flags
>> that would be used to propagate this information.
>> 
>> Remove the unused UFFD_FLAGS_SET to avoid confusion in the constant
>> names.
>> 
>> Introducing uffd flags also allows to avoid mm/userfaultfd from being
>> using uapi (e.g., UFFDIO_COPY_MODE_WP).
>> 
>> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
>> Cc: Hugh Dickins <hughd@xxxxxxxxxx>
>> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>> Cc: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>
>> Cc: Peter Xu <peterx@xxxxxxxxxx>
>> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx>
>> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
>> Signed-off-by: Nadav Amit <namit@xxxxxxxxxx>
>> ---
>> fs/userfaultfd.c              | 22 +++++++++++---
>> include/linux/hugetlb.h       |  4 +--
>> include/linux/shmem_fs.h      |  8 +++--
>> include/linux/userfaultfd_k.h | 24 +++++++++------
>> mm/hugetlb.c                  |  3 +-
>> mm/shmem.c                    |  6 ++--
>> mm/userfaultfd.c              | 57 ++++++++++++++++++-----------------
>> 7 files changed, 73 insertions(+), 51 deletions(-)
>> 
>> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
>> index e943370107d0..2ae24327beec 100644
>> --- a/fs/userfaultfd.c
>> +++ b/fs/userfaultfd.c
>> @@ -1682,6 +1682,8 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
>> 	struct uffdio_copy uffdio_copy;
>> 	struct uffdio_copy __user *user_uffdio_copy;
>> 	struct userfaultfd_wake_range range;
>> +	bool mode_wp;
>> +	uffd_flags_t uffd_flags;
>> 
>> 	user_uffdio_copy = (struct uffdio_copy __user *) arg;
>> 
>> @@ -1708,10 +1710,15 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
>> 		goto out;
>> 	if (uffdio_copy.mode & ~(UFFDIO_COPY_MODE_DONTWAKE|UFFDIO_COPY_MODE_WP))
>> 		goto out;
>> +
>> +	mode_wp = uffdio_copy.mode & UFFDIO_COPY_MODE_WP;
> 
> This seems to be the only place where mode_wp is used in this function. 
> I'd just drop it, and set uffd_flags directly from uffdio_copy.mode. E.g.
> something like
> 
> 	uffd_flags_t uffd_flags = UFFD_FLAGS_NONE;
> 
> 	...
> 
> 	if (uffdio_copy.mode & UFFDIO_COPY_MODE_WP)
> 		uffd_flags = UFFD_FLAGS_WP;

Good point; taken.






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux