Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] tracing/osnoise: WARN_ON triggered on restart with 
NO_OSNOISE_WORKLOAD
--

commit 0c861cff53ad6b5caf50d13aaff67f66512d0646
Author: Crystal Wood <[email protected]>

tracing/osnoise: start_kthread: Always check OSN_WORKLOAD

This commit modifies start_kthread() to check OSN_WORKLOAD up front and
return early if it is not set, instead of only checking it inside the
non-timerlat branch.

> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -2077,16 +2077,17 @@ static int start_kthread(unsigned int cpu)
>       if (osn->kthread)
>               goto out;
>  
> +     /* Can still happen with timerlat via cpu hotplug */
> +     if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
> +             if (!timerlat_enabled())
> +                     osn->sampling = true;
> +             goto out;

[Severity: Medium]
If OSN_WORKLOAD is not set, this code sets osn->sampling to true and
returns without creating a kthread. Later, when the tracer is stopped,
stop_kthread() does nothing because osn_var->kthread is NULL:

stop_kthread() {
    ...
    } else if (osn_var->kthread) {
        ...
        osn_reset_cpu(cpu);
    }
}

Because osn_reset_cpu() is skipped, the sampling state is leaked. When the
tracer is subsequently restarted, osn_var_reset() checks the state and
triggers a kernel warning:

osn_var_reset() {
    ...
    WARN_ON(osn->sampling);
    ...
}

Could this leave a stale sampling state that persists across tracer
stop/start, triggering a WARN_ON in osn_var_reset() and breaking the
restartability of the tracer without a workload?

> +     }
> +
>       if (timerlat_enabled()) {
>               snprintf(comm, 24, "timerlat/%d", cpu);
>               main = timerlat_main;
>       } else {

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=5

Reply via email to