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 10:04:03 -0700	[thread overview]
Message-ID: <CAJHvVciZc0mpcw8OSPk71YsVzCTajY+ikymcD3+zBJKsZynYkg@mail.gmail.com> (raw)
In-Reply-To: <YUp438W5p5VHL1Ch@t490s>

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.

On Tue, Sep 21, 2021 at 5:29 PM Peter Xu <peterx@redhat.com> wrote:
>
> On Tue, Sep 21, 2021 at 01:31:12PM -0700, Axel Rasmussen wrote:
> > Ah, it has to do with us asserting the list of expected ioctls. The
> > kernel changes the list of ioctls it reports in response to a
> > UFFDIO_REGISTER, depending on the particular kind of vma being
> > registered, **as well as what mode(s) it is being registered with**.
> >
> > So for example, consider the hugetlb_shared test. When registering,
> > the kernel might set the UFFDIO_CONTINUE bit or not, depending on
> > whether we registered with the MINOR mode bit set in particular.
>
> I can understand your point, but the "capability set" of the kernel is still
> the same.  In this case we should have UFFDIO_CONTINUE capability for
> hugetlb_shared test globally, as long as the kernel supports it, irrelevant of
> what test case we're going to have.
>
> Then in the test, if we don't register with MINOR mode, IMHO we should just
> mask out the expected_ioctls with UFFDIO_CONTINUE because it does not make
> sense to request UFFDIO_CONTINUE if we will never use it in the test.

Right, this is how it was before. I didn't love how the base set
included everything, and then each test is responsible for removing
the things it isn't testing. It seems reversed: why not just have each
test compute the set of things it *is* testing?

>
> In other words, having a "uffd_features" global variable and having it changing
> all the time during tests is odd to me, but I agree it's not a big deal. :)

100% agree with this. From my perspective this is tech debt since:

8ba6e86408 userfaultfd/selftests: reinitialize test context in each test

It used to be that we just had one global context (variables like
uffd, count_verify, area_src, area_dst, etc). But this had the problem
where some previous test can mutate the context, breaking or affecting
following tests. After 8ba6e86408, we clear and reinitialize all these
variables for each test, but they're still global. I think it would be
cleaner if these instead were in a struct, which each test initialized
and then destroyed within its own scope. If we were to do such a
refactor, I would put uffd_features in that struct too - it should be
private to a test, since it's a property we get from the uffd.

But, I wasn't sure it was worth the churn to do something like this.

>
> --
> Peter Xu
>


  reply	other threads:[~2021-09-22 17:04 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 [this message]
2021-09-22 17:32             ` Peter Xu
2021-09-22 20:54               ` Axel Rasmussen
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=CAJHvVciZc0mpcw8OSPk71YsVzCTajY+ikymcD3+zBJKsZynYkg@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).