linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Axel Rasmussen <axelrasmussen@google.com>
To: Peter Xu <peterx@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>,  Linux MM <linux-mm@kvack.org>,
	Linuxkselftest <linux-kselftest@vger.kernel.org>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] userfaultfd/selftests: fix feature support detection
Date: Wed, 22 Sep 2021 13:54:53 -0700	[thread overview]
Message-ID: <CAJHvVcg6PRCK_JcYEhRqq2vPyypnc+ySOtLhtFf5GrcQjimsJQ@mail.gmail.com> (raw)
In-Reply-To: <YUtoyNic4Jxfv9f7@t490s>

On Wed, Sep 22, 2021 at 10:33 AM Peter Xu <peterx@redhat.com> wrote:
>
> Hello, Axel,
>
> On Wed, Sep 22, 2021 at 10:04:03AM -0700, Axel Rasmussen wrote:
> > Thanks for discussing the design Peter. I have some ideas which might
> > make for a nicer v2; I'll massage the code a bit and see what I can
> > come up with.
>
> Sure thing.  Note again that as I don't have a strong opinion on that, feel
> free to keep it.  However if you provide v2, I'll read.
>
> [off-topic below]
>
> Another thing I probably have forgot but need your confirmation is, when you
> worked on uffd minor mode, did you explicitly disable thp, or is it allowed?

I gave a more detailed answer in the other thread, but: currently it
is allowed, but this was a bug / oversight on my part. :) THP collapse
can break the guarantees minor fault registration is trying to
provide.

I think your approach of checking the VMA flags *in
retract_page_tables specifically* is correct, and a similar thing
should be done for minor registered VMAs too.

>
> When I'm reworking the uffd-wp series, I noticed that commit e1e267c7928f
> ("khugepaged: skip collapse if uffd-wp detected", 2020-04-07) was actually
> awkward and not efficient, as we can simply lookup the vma flags for detecting
> uffd-wp enablement.  I'm preparing a patch for it to do it by checking vmas
> (and that patch will also pave the way for file-backed).
>
> Then I noticed we need similar thing for minor mode?
>
> I think the answer is yes, but I didn't see any code that explicitly handled
> thp for minor mode, do you remember?
>
> To be explicit, what if in mcontinue_atomic_pte() we get a shmem_getpage() call
> with a thp returned?  Will minor mode break?

Ah so this I am not quite as sure about.

The issue I was describing in the other thread was more about THP
collapse racing with UFFDIO_CONTINUE. E.g., collapsing after
registration has happened, but before faults have been resolved.

But there's another scenario: what if the collapse happened well
before registration happened? I *think* the existing code deals with
THPs correctly in that case, but then again I don't think our selftest
really covers this case, and it's not something I've tested in
production either (to work around the other bug, we currently
MADV_NOHUGEPAGE the area until after VM demand paging completes, and
the UFFD registration is removed), so I am not super confident this is
the case.

>
> I plan to post the khugepaged patch soon and I plan to cover minor mode too
> there, but I'm not sure whether that's enough, as the thp can be there from the
> 1st day I think, but I could have missed something.
>
> --
> Peter Xu
>


  reply	other threads:[~2021-09-22 20:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 16:33 [PATCH 1/3] userfaultfd/selftests: fix feature support detection Axel Rasmussen
2021-09-21 16:33 ` [PATCH 2/3] userfaultfd/selftests: fix calculation of expected ioctls Axel Rasmussen
2021-09-21 16:33 ` [PATCH 3/3] userfaultfd/selftests: don't rely on GNU extensions for random numbers Axel Rasmussen
2021-09-21 18:03   ` Peter Xu
2021-09-21 17:44 ` [PATCH 1/3] userfaultfd/selftests: fix feature support detection Peter Xu
2021-09-21 18:26   ` Axel Rasmussen
2021-09-21 19:21     ` Peter Xu
2021-09-21 20:31       ` Axel Rasmussen
2021-09-22  0:29         ` Peter Xu
2021-09-22 17:04           ` Axel Rasmussen
2021-09-22 17:32             ` Peter Xu
2021-09-22 20:54               ` Axel Rasmussen [this message]
2021-09-22 21:51                 ` Peter Xu
2021-09-22 22:29                   ` Axel Rasmussen
2021-09-22 23:49                     ` Peter Xu
2021-09-23  4:17                       ` James Houghton
2021-09-23  5:43                         ` Jue Wang
2021-09-24 20:09                           ` Peter Xu
2021-09-24 20:22                             ` Jue Wang

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=CAJHvVcg6PRCK_JcYEhRqq2vPyypnc+ySOtLhtFf5GrcQjimsJQ@mail.gmail.com \
    --to=axelrasmussen@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=shuah@kernel.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;
as well as URLs for NNTP newsgroup(s).