From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: David CARLIER <devnexen@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Josh Law <objecting@objecting.org>,
Dennis Zhou <dennis@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: fix compare_delta parameter order in percpu_counter_tree
Date: Sun, 15 Mar 2026 19:16:04 -0400 [thread overview]
Message-ID: <65bc70e0-c9a8-44b7-aa8e-3ffa31b0ed75@efficios.com> (raw)
In-Reply-To: <CA+XhMqzPRhHj=mMuk759Q2_-zujLirbJY5CZdQLPdqGVu7sX_w@mail.gmail.com>
On 2026-03-15 18:47, David CARLIER wrote:
> On Sun, 15 Mar 2026 at 22:00, Mathieu Desnoyers
[...]
> Any thought on how to extend the kunit
>> test to cover this ?
>
> Can something like this be applicable ?
>
> static void hpcc_test_compare_value_boundaries(struct kunit *test)
> {
> struct percpu_counter_tree pct;
> struct percpu_counter_tree_level_item *counter_items;
> unsigned long under = 0, over = 0;
> int ret;
>
> 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);
> KUNIT_ASSERT_EQ(test, ret, 0);
>
> percpu_counter_tree_set(&pct, 0);
> percpu_counter_tree_approximate_accuracy_range(&pct, &under, &over);
> > /* Skip if under == over (no gap to test) */
> if (under == over)
> goto out;
If we ever have over == under, then I think we could keep running this test,
but skip the "expect indeterminate" test items which depend on having
asymmetric ranges.
>
> /* Positive boundary: v = under should be indeterminate (precise
> could be up to +under) */
> KUNIT_EXPECT_EQ(test, 0,
> percpu_counter_tree_approximate_compare_value(&pct, (long)under));
>
> /* Positive boundary: v = over + 1 should be indeterminate */
> KUNIT_EXPECT_EQ(test, 0,
> percpu_counter_tree_approximate_compare_value(&pct,
> (long)(over + 1)));
This assumes that under > over, right ? In that case, I think we may
want to grab "under" and "over" values and copy them into a "a" and
"b" variables where a > b.
This way, the test does not cast on stone the library implementation
details: the fact that the "under" range is slightly larger than "over"
due to complement 2 +/- ranges.
Thanks!
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-03-15 23:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 17:54 David Carlier
2026-03-14 15:30 ` Josh Law
2026-03-14 21:45 ` Andrew Morton
2026-03-15 22:00 ` Mathieu Desnoyers
2026-03-15 22:47 ` David CARLIER
2026-03-15 23:16 ` Mathieu Desnoyers [this message]
2026-03-16 0:05 ` David CARLIER
2026-03-16 0:41 ` Mathieu Desnoyers
2026-03-16 4:28 ` David CARLIER
2026-03-16 13:06 ` Mathieu Desnoyers
2026-03-16 13:41 ` David CARLIER
2026-03-16 13:53 ` Mathieu Desnoyers
2026-03-16 14:15 ` David CARLIER
2026-03-16 14:15 ` David CARLIER
2026-03-16 14:23 ` Mathieu Desnoyers
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=65bc70e0-c9a8-44b7-aa8e-3ffa31b0ed75@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=dennis@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®