[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250814150654.28b0d04c@gandalf.local.home>
Date: Thu, 14 Aug 2025 15:06:54 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Fushuai Wang <wangfushuai@...du.com>
Cc: <linux-trace-kernel@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<mhiramat@...nel.org>, <mathieu.desnoyers@...icios.com>
Subject: Re: [PATCH] trace/hwlat: Add WARN_ON in move_to_next_cpu()
On Mon, 11 Aug 2025 16:01:09 +0800
Fushuai Wang <wangfushuai@...du.com> wrote:
> Add a WARN_ON check in move_to_next_cpu(). Next_cpu should
> never be greater than or equal to nr_cpu_ids.
>
> Signed-off-by: Fushuai Wang <wangfushuai@...du.com>
> ---
> kernel/trace/trace_hwlat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
> index 2f7b94e98317..5024b0dcdbba 100644
> --- a/kernel/trace/trace_hwlat.c
> +++ b/kernel/trace/trace_hwlat.c
> @@ -328,7 +328,7 @@ static void move_to_next_cpu(void)
> next_cpu = cpumask_next_wrap(raw_smp_processor_id(), current_mask);
> cpus_read_unlock();
>
> - if (next_cpu >= nr_cpu_ids) /* Shouldn't happen! */
> + if (WARN_ON(next_cpu >= nr_cpu_ids)) /* Shouldn't happen! */
> goto change_mode;
Yeah, it shouldn't happen but it doesn't mean we need to add a WARN_ON().
It might even happen if user space is messing with the tracing_cpumask at
the same time. It shouldn't happen but it doesn't mean it will not happen.
We do not add WARN_ON() for things that could be trigger by user space.
-- Steve
Powered by blists - more mailing lists