From: Brendan Jackman <jackmanb@google.com>
To: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <davidgow@google.com>, Rae Moar <rmoar@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Michal Hocko <mhocko@kernel.org>,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH RFC 4/4] mm/page_alloc_test: Add smoke-test for page allocation
Date: Tue, 25 Feb 2025 12:14:56 +0100 [thread overview]
Message-ID: <CA+i-1C1KL9uJALuU=ZND0U0HQoqihzyH6HoZhdKmmTQP25qDuw@mail.gmail.com> (raw)
In-Reply-To: <Z7y5vK1M5IOizIWR@google.com>
On Mon, 24 Feb 2025 at 19:26, Yosry Ahmed <yosry.ahmed@linux.dev> wrote:
> > +static void action_nodemask_free(void *ctx)
> > +{
> > + NODEMASK_FREE(ctx);
> > +}
> > +
> > +/*
> > + * Call __alloc_pages_noprof with a nodemask containing only the nid.
> > + *
> > + * Never returns NULL.
> > + */
> > +static inline struct page *alloc_pages_force_nid(struct kunit *test,
> > + gfp_t gfp, int order, int nid)
> > +{
> > + NODEMASK_ALLOC(nodemask_t, nodemask, GFP_KERNEL);
>
> For the sake of the test can't we just put the nodemask on the stack?
Hm, I think whether or not it's test code is irrelevant to whether we
can put it on the stack. Presumably the nodemask code is written as it
is because nodemasks can be massive, so we can overflow the stack here
just as easily and confusingly as anywhere else.
(I think we're not in a very deep stack here right now but KUnit could
easily change that).
FWIW I think when using the mm/.kunitconfig provided in this series it
does actually go on the stack.
> > + struct page *page;
> > +
> > + KUNIT_ASSERT_NOT_NULL(test, nodemask);
> > + kunit_add_action(test, action_nodemask_free, &nodemask);
>
> Why aren't we just freeing the nodemask after using it, before we make
> any assertions?
I guess that's just a philosophical question, I usually default to
writing KUnit code such that you can throw an assertion in ~anywhere
and things just work.
But, I'm not passionate about it, I would also be fine with freeing it
directly (it would certainly save quite a few lines of code).
> > +/* Generate test cases as the cross product of orders and alloc_fresh_gfps. */
> > +static const void *alloc_fresh_gen_params(const void *prev, char *desc)
> > +{
> > + /* Buffer to avoid allocations. */
> > + static struct alloc_fresh_test_case tc;
> > +
> > + if (!prev) {
> > + /* First call */
> > + tc.order = 0;
> > + tc.gfp_idx = 0;
> > + return &tc;
> > + }
>
> We need to set 'tc' here to whatever 'prev' is pointing at, right?
prev always points at tc (or is NULL). Sounds like it needs a comment
to that effect!
(Note tc is static).
Ack to everything else, thanks for the review!
next prev parent reply other threads:[~2025-02-25 11:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 14:47 [PATCH RFC 0/4] mm: KUnit tests for the page allocator Brendan Jackman
2025-02-24 14:47 ` [PATCH RFC 1/4] kunit: Allocate assertion data with GFP_ATOMIC Brendan Jackman
2025-02-24 14:47 ` [PATCH RFC 2/4] mm/page_alloc_test: Add empty KUnit boilerplate Brendan Jackman
2025-02-24 14:47 ` [PATCH RFC 3/4] mm/page_alloc_test: Add logic to isolate a node for testing Brendan Jackman
2025-02-24 18:33 ` Yosry Ahmed
2025-02-25 11:20 ` Brendan Jackman
2025-02-26 10:33 ` Brendan Jackman
2025-02-24 14:47 ` [PATCH RFC 4/4] mm/page_alloc_test: Add smoke-test for page allocation Brendan Jackman
2025-02-24 18:26 ` Yosry Ahmed
2025-02-25 11:14 ` Brendan Jackman [this message]
2025-02-26 10:47 ` Brendan Jackman
2025-02-25 10:01 ` [PATCH RFC 0/4] mm: KUnit tests for the page allocator David Hildenbrand
2025-02-25 12:56 ` Brendan Jackman
2025-02-26 11:52 ` David Hildenbrand
2025-02-26 12:21 ` Brendan Jackman
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='CA+i-1C1KL9uJALuU=ZND0U0HQoqihzyH6HoZhdKmmTQP25qDuw@mail.gmail.com' \
--to=jackmanb@google.com \
--cc=akpm@linux-foundation.org \
--cc=brendan.higgins@linux.dev \
--cc=david@redhat.com \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@kernel.org \
--cc=osalvador@suse.de \
--cc=rmoar@google.com \
--cc=vbabka@suse.cz \
--cc=yosry.ahmed@linux.dev \
/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