From: Ankur Arora <ankur.a.arora@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: Ankur Arora <ankur.a.arora@oracle.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v17 15/16] barrier: timeout validity checks for smp_cond_load_relaxed_timeout()
Date: Mon, 16 Nov 2026 23:26:35 -0600 [thread overview]
Message-ID: <871p8k2flg.fsf@oracle.com> (raw)
In-Reply-To: <sashiko-outbox-216561@kernel.org>
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] kunit: barrier: expiry_skip_test() skips invalid timeouts on
> arm64 WFXT
> --
>
> commit b346a6c0c892c3f1d3df9f9238d93e9e4a6dba04
> Author: Ankur Arora <ankur.a.arora@oracle.com>
>
> barrier: timeout validity checks for smp_cond_load_relaxed_timeout()
>
> This commit adds KUnit parameterized tests to verify how
> smp_cond_load_relaxed_timeout() handles invalid, out-of-range, and edge-case
> timeout values using a synthetic clock.
>
>> diff --git a/lib/tests/barrier_timeout_kunit.c b/lib/tests/barrier_timeout_kunit.c
>> index 63d82f05ca596..b6cdecf295747 100644
>> --- a/lib/tests/barrier_timeout_kunit.c
>> +++ b/lib/tests/barrier_timeout_kunit.c
>
> [ ... ]
>
>> @@ -113,8 +115,118 @@ static void test_smp_cond_timeout(struct kunit *test)
>> KUNIT_EXPECT_GE(test, runtime, timeout_ns);
>> }
>>
>> +static s64 synthetic_clock(struct clock_state *clk)
>> +{
>> + clk->end_time += clk->extra;
>> + clk->niters++;
>> +
>> + return clk->end_time;
>> +}
>> +
>> +struct smp_cond_expiry_params {
>> + char *desc;
>> + u64 timeout_ns;
>> + s64 clk_unit;
>> + s64 miniters;
>> + s64 maxiters;
>> +};
>> +
>> +static const struct smp_cond_expiry_params expiry_params_list[] = {
>> + /* timeout_ns is invalid/out-of-range */
>> + { .clk_unit = 0, .timeout_ns = -1LL, .miniters = -1, .maxiters = 0, .desc = "invalid (-1LL)", },
>> + { .clk_unit = 0, .timeout_ns = ~0ULL, .miniters = -1, .maxiters = 0, .desc = "invalid (~0ULL)", },
>> + { .clk_unit = 0, .timeout_ns = S64_MAX+1ULL, .miniters = -1, .maxiters = 0, .desc = "out-of-range (S64_MAX+1)", },
>> + { .clk_unit = 0, .timeout_ns = U64_MAX, .miniters = -1, .maxiters = 0, .desc = "out-of-range (U64_MAX)", },
>> + { .clk_unit = 0, .timeout_ns = 0, .miniters = -1, .maxiters = 1, .desc = "degenerate (0)", },
>> +
>> + /* timeout_ns is valid */
>> + { .clk_unit = (0x1ULL << 28), .timeout_ns = 1, .miniters = 1, .maxiters = -1, .desc = "1", },
>> + { .clk_unit = (0x1ULL << 28), .timeout_ns = (0x1ULL << 30), .miniters = 1 << (30-28), .maxiters = -1, .desc = "1<<30", },
>> + { .clk_unit = (0x1ULL << 28), .timeout_ns = S32_MAX, .miniters = 1 << (31-28), .maxiters = -1, .desc = "S32_MAX", },
>> + { .clk_unit = (0x1ULL << 28), .timeout_ns = U32_MAX, .miniters = 1 << (32-28), .maxiters = -1, .desc = "U32_MAX", },
>> + { .clk_unit = (0x1ULL << 28), .timeout_ns = (0x1ULL << 33), .miniters = 1 << (33-28), .maxiters = -1, .desc = "1<<33", },
>> +};
>
> [ ... ]
>
>> +static char *expiry_skip_test(const struct smp_cond_expiry_params *p)
>> +{
>> +#ifdef CONFIG_ARM64
>> +
>> + /*
>> + * WFXT waits for the full p->timeout_ns so limit it to a reasonable
>> + * duration.
>> + */
>> + if (alternative_has_cap_unlikely(ARM64_HAS_WFXT) &&
>> + p->timeout_ns >= NSEC_PER_SEC) {
>> +
>> + return "runtime duration too long";
>> + }
>> +#endif
>> + return NULL;
>> +}
>
> [Severity: Low]
> Does expiry_skip_test() skip the invalid and out-of-range test cases on
> arm64 systems with ARM64_HAS_WFXT?
>
> Because p->timeout_ns is a u64, values such as -1LL, ~0ULL, S64_MAX+1ULL,
> and U64_MAX all compare >= NSEC_PER_SEC in an unsigned comparison, even
> though smp_cond_load_relaxed_timeout() casts timeout_ns to s64 and returns
> immediately without entering the WFXT wait loop. Casting p->timeout_ns to
> s64 here (or checking p->maxiters != 0) would keep coverage for those test
> cases on WFXT-capable hardware.
There's no clean way to test with synthetic timeouts with WFET: unlike when
running with WFE, it waits for the specified duration.
In any case, the loss is not great: we test with WFET for small timeout values.
And, a fairly similar path is taken when the test runs with WFE.
--
ankur
next prev parent reply other threads:[~2026-11-17 5:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 8:24 [PATCH v17 00/16] barrier: Add smp_cond_load_{relaxed,acquire}_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 01/16] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:42 ` sashiko-bot
2026-11-17 5:30 ` Ankur Arora
2026-11-16 8:24 ` [PATCH v17 02/16] arm64: barrier: Support smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 03/16] arm64/delay: define arm64_wfet_deadline() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:46 ` sashiko-bot
2026-11-17 5:23 ` Ankur Arora
2026-11-16 8:24 ` [PATCH v17 05/16] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 06/16] asm-generic: barrier: Add smp_cond_load_acquire_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 07/16] atomic: Add atomic_cond_read_*_timeout() Ankur Arora
2026-11-16 8:49 ` sashiko-bot
2026-11-16 8:24 ` [PATCH v17 08/16] locking/atomic: scripts: build atomic_long_cond_read_*_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 09/16] bpf/rqspinlock: switch check_timeout() to a clock interface Ankur Arora
2026-11-16 8:24 ` [PATCH v17 10/16] bpf/rqspinlock: Use smp_cond_load_acquire_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 11/16] sched: add need-resched timed wait interface Ankur Arora
2026-11-16 8:24 ` [PATCH v17 12/16] cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 13/16] arm64/delay: enable testing smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 14/16] barrier: add tests for smp_cond_load_*_timeout() Ankur Arora
2026-11-16 8:24 ` [PATCH v17 15/16] barrier: timeout validity checks for smp_cond_load_relaxed_timeout() Ankur Arora
2026-11-16 8:45 ` sashiko-bot
2026-11-17 5:26 ` Ankur Arora [this message]
2026-11-16 8:24 ` [PATCH v17 16/16] barrier: timeout validity checks for smp_cond_load_acquire_timeout() Ankur Arora
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=871p8k2flg.fsf@oracle.com \
--to=ankur.a.arora@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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