mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: David Carlier <devnexen@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Josh Law <objecting@objecting.org>,
	Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: skip percpu_counter_tree boundary kunit tests on single-CPU
Date: Tue, 17 Mar 2026 11:41:46 -0400	[thread overview]
Message-ID: <5f6a0278-d3d0-42fe-a2bb-38917d4bbdc3@efficios.com> (raw)
In-Reply-To: <20260317153915.43559-1-devnexen@gmail.com>

On 2026-03-17 11:39, David Carlier wrote:
> On single-CPU topologies, accuracy_multiplier is zero, making both
> approx_accuracy_range.under and .over zero. The boundary tests in
> hpcc_test_compare_value_boundaries and hpcc_test_compare_counter_boundaries
> then degenerate to comparing 0 vs 0, which correctly returns 0 (equal)
> but the tests expect nonzero results.
> 
> Skip these boundary tests with kunit_skip() when accuracy is zero,
> since approximation boundaries are meaningless without multi-CPU carry
> propagation. Use percpu_counter_tree_items_size() as the topology check
> before any allocations to avoid leaking memory on skip.
> 
> Fixes: ebc1ff504f55 ("lib: add kunit boundary tests for percpu_counter_tree comparisons")
> Signed-off-by: David Carlier <devnexen@gmail.com>

Thanks!

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

> ---
>   lib/tests/percpu_counter_tree_kunit.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/lib/tests/percpu_counter_tree_kunit.c b/lib/tests/percpu_counter_tree_kunit.c
> index 4d058bc78f7d..b773d20867d4 100644
> --- a/lib/tests/percpu_counter_tree_kunit.c
> +++ b/lib/tests/percpu_counter_tree_kunit.c
> @@ -93,6 +93,9 @@ static void hpcc_test_compare_value_boundaries(struct kunit *test)
>   	unsigned long under = 0, over = 0;
>   	int ret;
>   
> +	if (!percpu_counter_tree_items_size())
> +		kunit_skip(test, "no approximation accuracy on single-CPU topology");
> +
>   	counter_items = kzalloc(percpu_counter_tree_items_size(), GFP_KERNEL);
>   	KUNIT_ASSERT_PTR_NE(test, counter_items, NULL);
>   	ret = percpu_counter_tree_init(&pct, counter_items, 32, GFP_KERNEL);
> @@ -197,6 +200,9 @@ static void hpcc_test_compare_counter_boundaries(struct kunit *test)
>   	unsigned long combined;
>   	int ret;
>   
> +	if (!percpu_counter_tree_items_size())
> +		kunit_skip(test, "no approximation accuracy on single-CPU topology");
> +
>   	counter_items = kzalloc(percpu_counter_tree_items_size() * 2,
>   				GFP_KERNEL);
>   	KUNIT_ASSERT_PTR_NE(test, counter_items, NULL);


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2026-03-17 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 15:06 David Carlier
2026-03-17 15:32 ` Mathieu Desnoyers
2026-03-17 15:39 ` David Carlier
2026-03-17 15:41   ` Mathieu Desnoyers [this message]
2026-03-17 15:54   ` Mark Brown
2026-03-17 16:09 ` Josh Law

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=5f6a0278-d3d0-42fe-a2bb-38917d4bbdc3@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=devnexen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=objecting@objecting.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

all inboxes | Powered by JetHome®