Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned

From: Peter Xu
Date: Mon Sep 28 2020 - 13:23:04 EST


On Mon, Sep 28, 2020 at 09:17:09AM -0700, Linus Torvalds wrote:
> On Mon, Sep 28, 2020 at 5:49 AM Jason Gunthorpe <jgg@xxxxxxxx> wrote:
> >
> > Not seeing an obvious option besides adding a smp_mb() before
> > page_maybe_dma_pinned() as Peter once suggested.
>
> That is going to be prohibitively expensive - needing it for each pte
> whether it's pinned or not.
>
> I really think the better option is a "don't do that then". This has
> _never_ worked before either except by pure luck.

Yes... Actually I am also thinking about the complete solution to cover
read-only fast-gups too, but now I start to doubt this, at least for the fork()
path. E.g. if we'd finally like to use pte_protnone() to replace the current
pte_wrprotect(), we'll be able to also block the read gups, but we'll suffer
the same degradation on normal fork()s, or even more. Seems unacceptable.

The other question is, whether we should emphasize and document somewhere that
MADV_DONTFORK is still (and should always be) the preferred way, because
changes like this series can potentially encourage the other way.

--
Peter Xu