linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Kees Cook <kees@kernel.org>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Vlastimil Babka <vbabka@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Eric Biederman <ebiederm@xmission.com>,
	Suren Baghdasaryan <surenb@google.com>
Subject: Re: [RFC PATCH 7/7] tools: add skeleton code for userland testing of VMA logic
Date: Thu, 27 Jun 2024 14:25:36 -0400	[thread overview]
Message-ID: <5zuowniex4sxy6l7erbsg5fiirf4d4f5fbpz2upay2igiwa2xk@vuezoh2wbqf4> (raw)
In-Reply-To: <202406270957.C0E5E8057@keescook>

* Kees Cook <kees@kernel.org> [240627 12:58]:
> On Thu, Jun 27, 2024 at 11:39:32AM +0100, Lorenzo Stoakes wrote:
> > Establish a new userland VMA unit testing implementation under
> > tools/testing which utilises existing logic providing maple tree support in
> > userland utilising the now-shared code previously exclusive to radix tree
> > testing.
> > 
> > This provides fundamental VMA operations whose API is defined in mm/vma.h,
> > while stubbing out superfluous functionality.
> > 
> > This exists as a proof-of-concept, with the test implementation functional
> > and sufficient to allow userland compilation of vma.c, but containing only
> > cursory tests to demonstrate basic functionality.
> 
> Interesting! Why do you want to have this in userspace instead of just
> wiring up what you have here to KUnit so testing can be performed by
> existing CI systems that are running all the KUnit tests?

The primary reason we did the maple tree testing in userspace was for
speed of testing.  We don't need to build the kernel, but a subset of
APIs.  Debugging problems is also much quicker since we can instrument
and rebuild, iterate down faster.  Tracing every call to the maple tree
on boot alone is massive.

It is also difficult to verify the vma correctness without exposing APIs
we don't want exported (or, I guess, parse proc files..).  On my side, I
have a module for testing the overall interface while I have more tests
on the userspace side that poke and prod on internal states, and
userspace rcu testing is possible.  I expect the same issues on the vma
side.

Adding tests can also be made very efficient with tracepoints dumping
something to add to an array, for example.

Finally, you have ultimate control on what other functions return (or
do) - so you can fail allocations to test error paths, for example.  Or
set the external function to fail after N allocations.  This comes in
handy when a syzbot reports a failed allocation at line X caused a
crash.

This has worked out phenomenally on the maple tree side.  I've been able
to record boot failures and import them, syzbot tests, and fuzzer tests.
The result is a huge list of tests that allowed me to rewrite my node
replacement algorithm and have it just work, once it passed the
collected tests.

I haven't used kunit as much as I have userspace testing, so I cannot
say if all of these points are not possible, but I didn't see a way to
test races like I do with rcu in userspace.

Thanks,
Liam


  reply	other threads:[~2024-06-27 18:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27 10:39 [RFC PATCH 0/7] Make core VMA operations internal and testable Lorenzo Stoakes
2024-06-27 10:39 ` [RFC PATCH 1/7] userfaultfd: move core VMA manipulation logic to mm/userfaultfd.c Lorenzo Stoakes
2024-06-27 10:39 ` [RFC PATCH 2/7] mm: move vma_modify() and helpers to internal header Lorenzo Stoakes
2024-06-27 17:25   ` Liam R. Howlett
2024-06-27 19:33     ` Lorenzo Stoakes
2024-06-27 10:39 ` [RFC PATCH 4/7] mm: move internal core VMA manipulation functions to own file Lorenzo Stoakes
2024-06-27 17:56   ` Liam R. Howlett
2024-06-27 19:41     ` Lorenzo Stoakes
2024-06-27 19:46       ` Liam R. Howlett
2024-06-27 10:39 ` [RFC PATCH 5/7] MAINTAINERS: Add entry for new VMA files Lorenzo Stoakes
2024-06-27 10:39 ` [RFC PATCH 6/7] tools: separate out shared radix-tree components Lorenzo Stoakes
2024-06-27 17:59   ` Liam R. Howlett
2024-06-27 19:46     ` Lorenzo Stoakes
2024-06-27 20:03       ` Liam R. Howlett
2024-06-27 20:39         ` Lorenzo Stoakes
2024-06-27 10:39 ` [RFC PATCH 7/7] tools: add skeleton code for userland testing of VMA logic Lorenzo Stoakes
2024-06-27 16:58   ` Kees Cook
2024-06-27 18:25     ` Liam R. Howlett [this message]
2024-06-27 19:31       ` Lorenzo Stoakes
2024-06-27 19:46         ` Kees Cook
2024-06-27 17:20   ` Liam R. Howlett
2024-06-27 19:25     ` Lorenzo Stoakes
2024-06-27 19:42       ` Liam R. Howlett
     [not found] ` <8c548bb3d0286bfaef2cd5e67d7bf698967a52a1.1719481836.git.lstoakes@gmail.com>
2024-06-27 17:45   ` [RFC PATCH 3/7] mm: unexport vma_expand() / vma_shrink() Liam R. Howlett
2024-06-27 19:38     ` Lorenzo Stoakes

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=5zuowniex4sxy6l7erbsg5fiirf4d4f5fbpz2upay2igiwa2xk@vuezoh2wbqf4 \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=jack@suse.cz \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.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