linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lstoakes@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.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>,
	Kees Cook <kees@kernel.org>,
	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 20:25:13 +0100	[thread overview]
Message-ID: <6bd118dd-de4b-4ccd-bdbe-f8c45e8ea783@lucifer.local> (raw)
In-Reply-To: <mefk223e65nkizav5yvz2djgyqprrw3uclyctvebdvr2crph34@cktxpmr6bdgq>

On Thu, Jun 27, 2024 at 01:20:30PM -0400, Liam R. Howlett wrote:
[snip]
> > +
> > +clean:
> > +	$(RM) $(TARGETS) *.o radix-tree.c idr.c generated/map-shift.h generated/bit-length.h
>
> This needs to clean out vma.c to avoid stale testing.
>
> But, none of this is needed.
>
> What we can do instead is add the correct header guards to the
> mm/vma_internal.h file, change the tools/testing/vma/vma_internal.h
> header guards to be the same (ie: remove TESTING_ from the existing
> ones), then we can include vma_internal.h into vma_stub.c prior to
> including "../../../mm/vma.c", and we don't need to copy the file.
>
> Essentially use the #ifdef guards to replace the header by ordering the
> local header for inclusion prior to the c file.

Ack this is a good idea, will do in v2.

>
>
> > diff --git a/tools/testing/vma/errors.txt b/tools/testing/vma/errors.txt
> > new file mode 100644
> > index 000000000000..e69de29bb2d1
> > diff --git a/tools/testing/vma/generated/autoconf.h b/tools/testing/vma/generated/autoconf.h
> > new file mode 100644
> > index 000000000000..92dc474c349b
> > --- /dev/null
> > +++ b/tools/testing/vma/generated/autoconf.h
> > @@ -0,0 +1,2 @@
> > +#include "bit-length.h"
> > +#define CONFIG_XARRAY_MULTI 1
> > diff --git a/tools/testing/vma/linux/atomic.h b/tools/testing/vma/linux/atomic.h
> > new file mode 100644
> > index 000000000000..298b0fb7aab2
> > --- /dev/null
> > +++ b/tools/testing/vma/linux/atomic.h
>
> This should have header guards as well.

Yup, the reason I kept it like this is because existing linux/*.h headers
in shared/linux didn't have header guards and I wanted to keep things in
line with that... will change.

>
> > @@ -0,0 +1,19 @@
> > +#ifndef atomic_t
> > +#define atomic_t int32_t
> > +#endif
> > +
> > +#ifndef atomic_inc
> > +#define atomic_inc(x) uatomic_inc(x)
> > +#endif
> > +
> > +#ifndef atomic_read
> > +#define atomic_read(x) uatomic_read(x)
> > +#endif
> > +
> > +#ifndef atomic_set
> > +#define atomic_set(x, y) do {} while (0)
> > +#endif
> > +
> > +#ifndef U8_MAX
> > +#define U8_MAX UCHAR_MAX
> > +#endif
> > diff --git a/tools/testing/vma/linux/mmzone.h b/tools/testing/vma/linux/mmzone.h
> > new file mode 100644
> > index 000000000000..71546e15bdd3
> > --- /dev/null
> > +++ b/tools/testing/vma/linux/mmzone.h
> > @@ -0,0 +1,37 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _TOOLS_MMZONE_H
> > +#define _TOOLS_MMZONE_H
>
> It might be best to use the same guards here to avoid mmzone.h from
> getting pulled in.

You mean the actual [root]/include/linux/mmzone.h ? Just deploying the same
header guard trick as mentioned above re: vma_internal.h?

[snip]

> > new file mode 100644
> > index 000000000000..b29eeb0daf31
> > --- /dev/null
> > +++ b/tools/testing/vma/main.c
>
> If you employ the use of header guards, we can rename main.c to vma.c
> and produce the executable "vma" instead of "main".

Sure, will do.

>
> > @@ -0,0 +1,161 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +
> > +#include <assert.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +
> > +#include "maple-shared.h"
> > +#include "vma_internal.h"
> > +#include "vma.h"
>
> You can directly include "../../../mm/vma.h" here and remove the vma.h
> file you have in this directory.

This was, I think, to keep to a convention, but you're right I don't think
there's any reason to do this, will change.

[snip]

> > +int main(void)
> > +{
> > +	maple_tree_init();
> > +
> > +	test_simple_merge();
> > +	test_simple_modify();
> > +	test_simple_expand();
> > +	test_simple_shrink();
> > +
> > +	return EXIT_SUCCESS;
> > +}
>
> It would be nice to have some output stating the number of tests
> passed/failed.

Ack, will add.

>
> > diff --git a/tools/testing/vma/vma.h b/tools/testing/vma/vma.h
> > new file mode 100644
> > index 000000000000..87a6cb222b63
> > --- /dev/null
> > +++ b/tools/testing/vma/vma.h
> > @@ -0,0 +1,3 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +
> > +#include "../../../mm/vma.h"
>
> I'd rather just drop this file and have this line in main.c (or vma.c if
> you decide to rename it).

Ack, will do.

[snip]


  reply	other threads:[~2024-06-27 19: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
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 [this message]
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=6bd118dd-de4b-4ccd-bdbe-f8c45e8ea783@lucifer.local \
    --to=lstoakes@gmail.com \
    --cc=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=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