From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Wupeng Ma <mawupeng1@huawei.com>
Cc: <rostedt@goodmis.org>, <mathieu.desnoyers@efficios.com>,
<linux-kernel@vger.kernel.org>,
<linux-trace-kernel@vger.kernel.org>
Subject: Re: [PATCH] ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free
Date: Tue, 6 Jan 2026 09:52:27 +0900 [thread overview]
Message-ID: <20260106095227.fb363651e87e5aa1855779bc@kernel.org> (raw)
In-Reply-To: <20251228065008.2396573-1-mawupeng1@huawei.com>
On Sun, 28 Dec 2025 14:50:07 +0800
Wupeng Ma <mawupeng1@huawei.com> wrote:
> When user resize all trace ring buffer through file 'buffer_size_kb',
> then in ring_buffer_resize(), kernel allocates buffer pages for each
> cpu in a loop.
>
> If the kernel preemption model is PREEMPT_NONE and there are many cpus
> and there are many buffer pages to be freed, it may not give up cpu
> for a long time and finally cause a softlockup.
>
> To avoid it, call cond_resched() after each cpu buffer free as Commit
> f6bd2c92488c ("ring-buffer: Avoid softlockup in ring_buffer_resize()")
> does.
>
> Detailed call trace as follow:
>
> rcu: INFO: rcu_sched self-detected stall on CPU
> rcu: 24-....: (14837 ticks this GP) idle=521c/1/0x4000000000000000 softirq=230597/230597 fqs=5329
> rcu: (t=15004 jiffies g=26003221 q=211022 ncpus=96)
> CPU: 24 UID: 0 PID: 11253 Comm: bash Kdump: loaded Tainted: G EL 6.18.2+ #278 NONE
> pc : arch_local_irq_restore+0x8/0x20
> arch_local_irq_restore+0x8/0x20 (P)
> free_frozen_page_commit+0x28c/0x3b0
> __free_frozen_pages+0x1c0/0x678
> ___free_pages+0xc0/0xe0
> free_pages+0x3c/0x50
> ring_buffer_resize.part.0+0x6a8/0x880
> ring_buffer_resize+0x3c/0x58
> __tracing_resize_ring_buffer.part.0+0x34/0xd8
> tracing_resize_ring_buffer+0x8c/0xd0
> tracing_entries_write+0x74/0xd8
> vfs_write+0xcc/0x288
> ksys_write+0x74/0x118
> __arm64_sys_write+0x24/0x38
>
> Signed-off-by: Wupeng Ma <mawupeng1@huawei.com>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks!
> ---
> kernel/trace/ring_buffer.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index afcd3747264d2..3ba08fc1b7d05 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -3121,6 +3121,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
> list) {
> list_del_init(&bpage->list);
> free_buffer_page(bpage);
> +
> + cond_resched();
> }
> }
> out_err_unlock:
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2026-01-06 0:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-28 6:50 [PATCH] ring-buffer: Avoid softlockup in ring_buffer_resize() during memory free Wupeng Ma
2026-01-06 0:52 ` Masami Hiramatsu [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=20260106095227.fb363651e87e5aa1855779bc@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=mawupeng1@huawei.com \
--cc=rostedt@goodmis.org \
/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