From: Peter Xu <peterx@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jann Horn <jannh@google.com>, Linux-MM <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Marty Mcfadden <mcfadden8@llnl.gov>,
Andrea Arcangeli <aarcange@redhat.com>,
Christoph Hellwig <hch@lst.de>, Oleg Nesterov <oleg@redhat.com>,
Kirill Shutemov <kirill@shutemov.name>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH v2] mm/gup: Allow real explicit breaking of COW
Date: Tue, 11 Aug 2020 11:27:57 -0400 [thread overview]
Message-ID: <20200811152757.GC132381@xz-x1> (raw)
In-Reply-To: <CAHk-=wgyrfrpRvM8CYiiZR8s7MKC_exFDw=mPGnEKzqXBcYJxA@mail.gmail.com>
On Tue, Aug 11, 2020 at 08:05:22AM -0700, Linus Torvalds wrote:
> On Mon, Aug 10, 2020 at 4:39 PM Jann Horn <jannh@google.com> wrote:
> >
> > The way I understand Peter, he doesn't want to avoid doing COW; he
> > wants to decouple userfaultfd-WP's fault handling from COW, so that
> > userfaultfd-wp notifies only when a previously-write-protected page is
> > actually written to. In other words, he wants the COW to basically
> > happen as it happens now, but it should only create a readonly PTE;
> > and if someone later triggers a real write fault, the fault handling
> > path would run again, and this time userfaultfd-wp would be notified
> > before that readonly PTE is turned into a writable one.
Yes, that's what I meant. Appreciate your help, Jann.
>
> Ahh.
>
> A light goes on.
>
> Thank you.
>
> And apologies to Peter - I misread that patch entirely.
>
> That said, now that I (finally) understand what Peter wants to do, I
> don't think the patch does what you say.
>
> Because the GUP will now indeed avoid userfaultfd-wp unless it's
> _actually_ a write, but then any reads will cause a COW that turns
> things writable. There is no second fault.
>
> So now later writes will never cause any userfaultfd-wp notifications at all.
>
> Which for all I know might be acceptable and ok, but it seems to be
> against userfaultfd rules, and against the whole synchronization idea.
>
> So I think the patch is broken, but I'm less fundamentally concerned about it.
>
> Because at that point, it's "only" userfaultfd that might break.
Right, v2 is broken on that. That's why I pasted another chunk in my previous
reply to still inherit the UFFD_WP bit even for COW [1]. Previously it was not
needed because UFFD_WP must have been turned off for the pte/pmd/.. before COW
happens. However with enforced COW that's not guaranteed any more.
I'll post v3 soon.
[1] https://lore.kernel.org/lkml/20200810191520.GA132381@xz-x1/
Thanks,
--
Peter Xu
prev parent reply other threads:[~2020-08-11 15:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 14:57 Peter Xu
2020-08-10 16:47 ` Linus Torvalds
2020-08-10 19:15 ` Peter Xu
2020-08-10 20:51 ` Linus Torvalds
2020-08-10 20:59 ` Linus Torvalds
2020-08-10 21:57 ` Peter Xu
2020-08-10 23:19 ` Linus Torvalds
2020-08-10 23:38 ` Jann Horn
2020-08-11 15:05 ` Linus Torvalds
2020-08-11 15:27 ` Peter Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200811152757.GC132381@xz-x1 \
--to=peterx@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcfadden8@llnl.gov \
--cc=oleg@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox