From: Steven Rostedt <rostedt@goodmis.org>
To: Fushuai Wang <wangfushuai@baidu.com>
Cc: <linux-trace-kernel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <mhiramat@kernel.org>,
<mathieu.desnoyers@efficios.com>
Subject: Re: [PATCH] trace/hwlat: Add WARN_ON in move_to_next_cpu()
Date: Thu, 14 Aug 2025 15:06:54 -0400 [thread overview]
Message-ID: <20250814150654.28b0d04c@gandalf.local.home> (raw)
In-Reply-To: <20250811080109.8417-1-wangfushuai@baidu.com>
On Mon, 11 Aug 2025 16:01:09 +0800
Fushuai Wang <wangfushuai@baidu.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@baidu.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
prev parent reply other threads:[~2025-08-14 19:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 8:01 [PATCH] trace/hwlat: Add WARN_ON in move_to_next_cpu() Fushuai Wang
2025-08-14 19:06 ` Steven Rostedt [this message]
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=20250814150654.28b0d04c@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=wangfushuai@baidu.com \
/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