lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+EESO5ny0L8qiB6_b8t9guCVj6+ygjKf5+x6bR2aXjEcJE5Rg@mail.gmail.com>
Date: Wed, 13 Aug 2025 07:15:00 -0700
From: Lokesh Gidra <lokeshgidra@...gle.com>
To: Barry Song <21cnbao@...il.com>
Cc: akpm@...ux-foundation.org, aarcange@...hat.com, linux-mm@...ck.org, 
	linux-kernel@...r.kernel.org, ngeoffray@...gle.com, 
	Suren Baghdasaryan <surenb@...gle.com>, Kalesh Singh <kaleshsingh@...gle.com>, 
	Barry Song <v-songbaohua@...o.com>, David Hildenbrand <david@...hat.com>, Peter Xu <peterx@...hat.com>
Subject: Re: [PATCH v4] userfaultfd: opportunistic TLB-flush batching for
 present pages in MOVE

On Wed, Aug 13, 2025 at 2:29 AM Barry Song <21cnbao@...il.com> wrote:
>
> On Tue, Aug 12, 2025 at 11:50 PM Lokesh Gidra <lokeshgidra@...gle.com> wrote:
>
> > > [...]
> > >
> > > >         /*
> > > > @@ -1257,7 +1327,7 @@ static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd,
> > > >                 if (!(mode & UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES))
> > > >                         err = -ENOENT;
> > > >                 else /* nothing to do to move a hole */
> > > > -                       err = 0;
> > > > +                       err = PAGE_SIZE;
> > >
> > > To be honest, I find `err = PAGE_SIZE` quite odd :-) Could we refine the
> > > code to make it more readable?
> > >
> > Agreed! I'll replace 'err' with 'ret' as the function no longer only
> > returns error but also bytes-moved if there is no error.
> >
>
> Looks good. Should we also include the following?
>
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -1246,6 +1246,7 @@ static int move_zeropage_pte(struct mm_struct *mm,
>  /*
>   * The mmap_lock for reading is held by the caller. Just move the page(s)
>   * from src_pmd to dst_pmd if possible, and return number of bytes moved.
> + * On failure, an error code is returned instead
>   */
>  static long move_pages_ptes(struct mm_struct *mm, pmd_t *dst_pmd,
> pmd_t *src_pmd,
>                             struct vm_area_struct *dst_vma,
>
>
Of course. I'll add this.
> > > [...]
> > >
> > > > @@ -1857,10 +1930,13 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start,
> > > >                                 break;
> > > >                         }
> > > >
> > > > -                       err = move_pages_pte(mm, dst_pmd, src_pmd,
> > > > -                                            dst_vma, src_vma,
> > > > -                                            dst_addr, src_addr, mode);
> > > > -                       step_size = PAGE_SIZE;
> > > > +                       ret = move_pages_ptes(mm, dst_pmd, src_pmd,
> > > > +                                             dst_vma, src_vma, dst_addr,
> > > > +                                             src_addr, src_end - src_addr, mode);
> > > > +                       if (ret < 0)
> > > > +                               err = ret;
> > > > +                       else
> > > > +                               step_size = ret;
> > >
> > > also looks a bit strange :-)
> >
> > Any suggestions on how to improve this? 'step_size' is expected to be
> > different in each iteration of the loop even without this patch.
>
> Usually, we have:
>
> if (ret < 0) {
>     goto or break things;
> }
> step_size = ret;
>
> Given the context, it does seem quite tricky to handle. I’m not sure,
> so maybe your code is fine. :-)

Yeah, the special handling for -EAGAIN warrants the current
implementation. I'll keep it as is then.

Thanks
>
> > >
> > > >                 }
> > > >
> > > >                 cond_resched();
> > > >
> > > > base-commit: 561c80369df0733ba0574882a1635287b20f9de2
> > > > --
> > > > 2.50.1.703.g449372360f-goog
>
> Thanks
> Barry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ