From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Zheng Yejian <zhengyejian@huaweicloud.com>
Cc: rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Mitigate possible softlockup in __tracing_open()
Date: Mon, 26 Aug 2024 00:05:31 +0900 [thread overview]
Message-ID: <20240826000531.5ff4cc3c3d6a48ecc26069dd@kernel.org> (raw)
In-Reply-To: <20240824030343.3218618-1-zhengyejian@huaweicloud.com>
On Sat, 24 Aug 2024 11:03:43 +0800
Zheng Yejian <zhengyejian@huaweicloud.com> wrote:
> In __tracing_open(), when max latency tracers took place on the cpu,
> the time start of its buffer would be updated, then event entries with
> timestamps being earlier than start of the buffer would be skipped
> (see tracing_iter_reset()).
>
> Softlockup will occur if the kernel is non-preemptible and too many
> entries were skipped in the loop that reset every cpu buffer, so add
> cond_resched() to avoid it.
>
> Signed-off-by: Zheng Yejian <zhengyejian@huaweicloud.com>
> ---
> kernel/trace/trace.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index ebe7ce2f5f4a..88faa95b457b 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -4706,6 +4706,15 @@ __tracing_open(struct inode *inode, struct file *file, bool snapshot)
> for_each_tracing_cpu(cpu) {
> ring_buffer_read_start(iter->buffer_iter[cpu]);
> tracing_iter_reset(iter, cpu);
> + /*
> + * When max latency tracers took place on the cpu, the time start
> + * of its buffer would be updated, then event entries with timestamps
> + * being earlier than start of the buffer would be skipped
> + * (see tracing_iter_reset()). Softlockup will occur if the kernel
> + * is non-preemptible and too many entries were skipped in the loop,
> + * so add cond_resched() to mitigate it.
> + */
> + cond_resched();
OK, but why we cond_resched() only here? Another tracing_iter_reset() in
s_start() does not cause the soft lockups in the same situation?
Thank you,
> }
> } else {
> cpu = iter->cpu_file;
> --
> 2.25.1
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2024-08-25 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-24 3:03 [PATCH] tracing: Mitigate possible softlockup in __tracing_open() Zheng Yejian
2024-08-25 15:05 ` Masami Hiramatsu [this message]
2024-08-26 2:55 ` Zheng Yejian
2024-08-26 14:35 ` Steven Rostedt
2024-08-27 1:29 ` Zheng Yejian
2024-08-27 11:52 ` Steven Rostedt
2024-08-27 12:46 ` [PATCH v2] tracing: Avoid possible softlockup in tracing_iter_reset() Zheng Yejian
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=20240826000531.5ff4cc3c3d6a48ecc26069dd@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=zhengyejian@huaweicloud.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