Re: [PATCH v8 05/14] rv: Add a KUnit test for the storage free path

From: Gabriele Monaco

Date: Fri Nov 20 2026 - 12:02:57 EST


On Fri, 2026-11-06 at 01:49 +0800, wen.yang@xxxxxxxxx wrote:
> +static void rv_test_rvtest_arm_after_destroy(struct kunit *test)
> +{
> + const int id = 4242;
> + struct da_monitor *stale;
> +
> + atomic_set(&rvtest_expired, 0);
> + da_monitor_init();
> + rv_this.enabled = 1;
> +
> + da_handle_start_run_event(id, NULL, start_rvtest);
> +
> + scoped_guard(rcu) /* resolve before the unlink
> */
> + stale = da_get_monitor(id, NULL);
> + KUNIT_ASSERT_NOT_NULL(test, stale);
> +
> + da_destroy_storage(id); /* cancel, unlink,
> call_rcu */
> + ha_start_timer_ns(to_ha_monitor(stale), clk_rvtest,
> +   RVTEST_BUDGET_NS, ha_get_ns());

Like sashiko suggested, you aren't really supposed to use stale outside the same
RCU window, the scoped guard should probably come up to here.

> +
> + rcu_barrier();
> +
> + /* A timer the free path missed expires here. */
> + msleep(600);

This feels like a magic number, are you trying to say something like wait for
twice the budget?
Something more explicit would probably be better.

Thanks,
Gabriele

> + KUNIT_EXPECT_EQ(test, atomic_read(&rvtest_expired), 0);
> + da_monitor_destroy();
> + rv_this.enabled = 0;
> +}
> +
>  static struct kunit_case rv_ha_kunit_cases[] = {
>   KUNIT_CASE(rv_test_rvtest_underflow),
> + KUNIT_CASE(rv_test_rvtest_arm_after_destroy),
>   {}
>  };
>