[PATCH v13 15/15] barrier: add clock tests for smp_cond_load_relaxed_timeout()

bot+bpf-ci at kernel.org bot+bpf-ci at kernel.org
Wed Jul 1 19:11:53 PDT 2026


> diff --git a/lib/tests/barrier-timeout-test.c b/lib/tests/barrier-timeout-test.c
> index 4226fb6456b3..ec78f8533006 100644
> --- a/lib/tests/barrier-timeout-test.c
> +++ b/lib/tests/barrier-timeout-test.c

[ ... ]

> @@ -112,8 +114,64 @@ 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;
> +	s64	timeout;
> +	s64	clk_inc;
> +	u32	niters;
> +};
> +
> +static const struct smp_cond_expiry_params expiry_params_list[] = {
> +	{ .clk_inc = (0x1ULL << 28), .timeout = 0,		.niters = 1,			.desc = "0",    },
> +	{ .clk_inc = (0x1ULL << 28), .timeout = 1,		.niters = 2,			.desc = "1",    },
> +	{ .clk_inc = (0x1ULL << 28), .timeout = (0x1ULL << 30), .niters = 1 + (1 << (30-28)),	.desc = "1<<30",   },
> +	{ .clk_inc = (0x1ULL << 28), .timeout = S32_MAX,	.niters = 1 + (1 << (31-28)),	.desc = "S32_MAX", },
> +	{ .clk_inc = (0x1ULL << 28), .timeout = U32_MAX,	.niters = 1 + (1 << (32-28)),	.desc = "U32_MAX", },
> +	{ .clk_inc = (0x1ULL << 28), .timeout = (0x1ULL << 33), .niters = 1 + (1 << (33-28)),	.desc = "1<<33",   },
> +};
> +
> +static void expiry_param_to_desc(const struct smp_cond_expiry_params *p, char *desc)
> +{
> +	snprintf(desc, KUNIT_PARAM_DESC_SIZE, "smp_cond_%s_timeout: clock-%s, timeout=%s, iterations=%u",
> +		"relaxed", "synthetic", p->desc, p->niters);
> +}

This isn't a bug, but since "relaxed" and "synthetic" never vary here,
could they be written directly into the format string rather than passed
through %s?

> +
> +static void test_smp_cond_expiry(struct kunit *test)
> +{
> +	const struct smp_cond_expiry_params *p = test->param_value;
> +	struct clock_state clk = {
> +		.start_time = 0,
> +		.end_time = 0,
> +		.extra = p->clk_inc,
> +		.niters = 0,
> +	};
> +	s64 runtime;
> +
> +	flag = 0;
> +	smp_cond_load_relaxed_timeout(&flag,
> +				      0,
> +				      synthetic_clock(&clk),
> +				      p->timeout);
> +
> +	runtime = (u64)clk.end_time - (u64)clk.start_time;
> +	KUNIT_EXPECT_EQ(test, clk.niters, p->niters);
> +	KUNIT_EXPECT_GE(test, runtime, p->timeout);
> +}
> +
> +
> +KUNIT_ARRAY_PARAM(smp_cond_expiry_params, expiry_params_list, expiry_param_to_desc);
>  static struct kunit_case barrier_timeout_test_cases[] = {
>  	KUNIT_CASE_PARAM(test_smp_cond_timeout, smp_cond_update_params_gen_params),
> +	KUNIT_CASE_PARAM(test_smp_cond_expiry, smp_cond_expiry_params_gen_params),
>  	{}
>  };


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/28559763019


More information about the linux-arm-kernel mailing list