Re: [PATCH RFC] mm: userfaultfd: correct dirty flags set for both present and swap pte

From: Lokesh Gidra
Date: Thu May 08 2025 - 11:28:01 EST


Thanks Barry for fixing this.

On Thu, May 8, 2025 at 8:24 AM Peter Xu <peterx@xxxxxxxxxx> wrote:
>
> On Thu, May 08, 2025 at 09:07:35PM +1200, Barry Song wrote:
> > From: Barry Song <v-songbaohua@xxxxxxxx>
> >
> > As David pointed out, what truly matters for mremap and userfaultfd
> > move operations is the soft dirty bit. The current comment and
> > implementation—which always sets the dirty bit for present PTEs
> > and fails to set the soft dirty bit for swap PTEs—are incorrect.

Can you please briefly describe the consequences of not setting the
soft-dirty bit? I'm wondering if it needs to be backported as a fix?

> > This patch updates the behavior to correctly set the soft dirty bit
> > for both present and swap PTEs in accordance with mremap.
> >
> > Reported-by: David Hildenbrand <david@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/linux-mm/02f14ee1-923f-47e3-a994-4950afb9afcc@xxxxxxxxxx/
> > Cc: Peter Xu <peterx@xxxxxxxxxx>
> > Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> > Cc: Lokesh Gidra <lokeshgidra@xxxxxxxxxx>
> > Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
>
> Acked-by: Peter Xu <peterx@xxxxxxxxxx>
>
> --
> Peter Xu
>