Re: [PATCH] lib: skip percpu_counter_tree boundary kunit tests on single-CPU
From: Josh Law
Date: Tue Mar 17 2026 - 12:16:16 EST
On 17 March 2026 15:06:38 GMT, David Carlier <devnexen@xxxxxxxxx> 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.
>
>Fixes: ebc1ff504f55 ("lib: add kunit boundary tests for percpu_counter_tree comparisons")
>Signed-off-by: David Carlier <devnexen@xxxxxxxxx>
>---
> 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..609992bfaa21 100644
>--- a/lib/tests/percpu_counter_tree_kunit.c
>+++ b/lib/tests/percpu_counter_tree_kunit.c
>@@ -101,6 +101,9 @@ static void hpcc_test_compare_value_boundaries(struct kunit *test)
> percpu_counter_tree_set(&pct, 0);
> percpu_counter_tree_approximate_accuracy_range(&pct, &under, &over);
>
>+ if (!under && !over)
>+ kunit_skip(test, "no approximation accuracy on single-CPU topology");
>+
> /*
> * With approx_sum = precise_sum = 0, from the accuracy invariant:
> * approx_sum - over <= precise_sum <= approx_sum + under
>@@ -214,6 +217,9 @@ static void hpcc_test_compare_counter_boundaries(struct kunit *test)
> */
> combined = under + over;
>
>+ if (!combined)
>+ kunit_skip(test, "no approximation accuracy on single-CPU topology");
>+
> /* --- percpu_counter_tree_approximate_compare --- */
>
> /* At boundary: indeterminate */
Keep it up!
Have a great day!
Reviewed-by: Josh Law <objecting@xxxxxxxxxxxxx>
V/R
Josh Law