All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Arnd Bergmann <arnd@kernel.org>,
	John Ogness <john.ogness@linutronix.de>,
	Arnd Bergmann <arnd@arndb.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] printk: kunit: support offstack cpumask
Date: Mon, 23 Jun 2025 12:38:33 +0200	[thread overview]
Message-ID: <aFkuqaFn3BOvsPT-@pathway.suse.cz> (raw)
In-Reply-To: <20250623075943-44fdf86a-adcd-478c-bf78-906145678adb@linutronix.de>

On Mon 2025-06-23 08:03:29, Thomas Weißschuh wrote:
> On Fri, Jun 20, 2025 at 09:25:20PM +0200, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > 
> > For large values of CONFIG_NR_CPUS, the newly added kunit test fails
> > to build:
> > 
> > kernel/printk/printk_ringbuffer_kunit_test.c: In function 'test_readerwriter':
> > kernel/printk/printk_ringbuffer_kunit_test.c:279:1: error: the frame size of 1432 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
> > 
> > Change this to use cpumask_var_t and allocate it dynamically when
> > CONFIG_CPUMASK_OFFSTACK is set.
> > 
> > Fixes: 5ea2bcdfbf46 ("printk: ringbuffer: Add KUnit test")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  kernel/printk/printk_ringbuffer_kunit_test.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> > 
> > diff --git a/kernel/printk/printk_ringbuffer_kunit_test.c b/kernel/printk/printk_ringbuffer_kunit_test.c
> > index 4081ae051d8e..9f79bc91246e 100644
> > --- a/kernel/printk/printk_ringbuffer_kunit_test.c
> > +++ b/kernel/printk/printk_ringbuffer_kunit_test.c
> > @@ -227,9 +227,12 @@ static void test_readerwriter(struct kunit *test)
> >  	struct prbtest_thread_data *thread_data;
> >  	struct prbtest_data *test_data;
> >  	struct task_struct *thread;
> > -	cpumask_t test_cpus;
> > +	cpumask_var_t test_cpus;
> >  	int cpu, reader_cpu;
> >  
> > +	if (alloc_cpumask_var(&test_cpus, GFP_KERNEL))
> > +		return;
> 
> IMO this shouldn't fail silently and instead should do:
> 
> KUNIT_FAIL_AND_ABORT(test, "Unable to allocate cpumask");

Also we need to call kunit_add_action_or_reset() to free the mask
when the test fails (aborts) instead of the free_cpumask_var() below.

The following changes on it top of this patch worked for me:

diff --git a/kernel/printk/printk_ringbuffer_kunit_test.c b/kernel/printk/printk_ringbuffer_kunit_test.c
index 9f79bc91246e..850e5240222c 100644
--- a/kernel/printk/printk_ringbuffer_kunit_test.c
+++ b/kernel/printk/printk_ringbuffer_kunit_test.c
@@ -203,6 +203,7 @@ static int prbtest_reader(struct prbtest_data *test_data, unsigned long timeout_
 	return 0;
 }
 
+KUNIT_DEFINE_ACTION_WRAPPER(prbtest_cpumask_cleanup, free_cpumask_var, cpumask_var_t);
 KUNIT_DEFINE_ACTION_WRAPPER(prbtest_kthread_cleanup, kthread_stop, struct task_struct *);
 
 static void prbtest_add_kthread_cleanup(struct kunit *test, struct task_struct *kthread)
@@ -229,9 +230,11 @@ static void test_readerwriter(struct kunit *test)
 	struct task_struct *thread;
 	cpumask_var_t test_cpus;
 	int cpu, reader_cpu;
+	int err;
 
-	if (alloc_cpumask_var(&test_cpus, GFP_KERNEL))
-		return;
+	KUNIT_ASSERT_TRUE(test, alloc_cpumask_var(&test_cpus, GFP_KERNEL));
+	err = kunit_add_action_or_reset(test, prbtest_cpumask_cleanup, test_cpus);
+	KUNIT_ASSERT_EQ(test, err, 0);
 
 	cpus_read_lock();
 	/*
@@ -279,8 +282,6 @@ static void test_readerwriter(struct kunit *test)
 	prbtest_reader(test_data, runtime_ms);
 
 	kunit_info(test, "completed test\n");
-
-	free_cpumask_var(test_cpus);
 }
 
 static struct kunit_case prb_test_cases[] = {


Arnd, could you pleae send v2 with the above changes?

Best Regards,
Petr

      reply	other threads:[~2025-06-23 10:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 19:25 [PATCH] printk: kunit: support offstack cpumask Arnd Bergmann
2025-06-20 19:28 ` Arnd Bergmann
2025-06-23  6:03 ` Thomas Weißschuh
2025-06-23 10:38   ` Petr Mladek [this message]

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=aFkuqaFn3BOvsPT-@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=thomas.weissschuh@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.