lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+i-1C1KL9uJALuU=ZND0U0HQoqihzyH6HoZhdKmmTQP25qDuw@mail.gmail.com>
Date: Tue, 25 Feb 2025 12:14:56 +0100
From: Brendan Jackman <jackmanb@...gle.com>
To: Yosry Ahmed <yosry.ahmed@...ux.dev>
Cc: Brendan Higgins <brendan.higgins@...ux.dev>, David Gow <davidgow@...gle.com>, 
	Rae Moar <rmoar@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>, 
	David Hildenbrand <david@...hat.com>, Oscar Salvador <osalvador@...e.de>, 
	Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Vlastimil Babka <vbabka@...e.cz>, 
	Michal Hocko <mhocko@...nel.org>, linux-kselftest@...r.kernel.org, 
	kunit-dev@...glegroups.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH RFC 4/4] mm/page_alloc_test: Add smoke-test for page allocation

On Mon, 24 Feb 2025 at 19:26, Yosry Ahmed <yosry.ahmed@...ux.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!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ