mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate
@ 2026-11-04 22:25 Christian Aurich Zanettini Martins
  2026-11-09  9:29 ` Vincent Donnefort
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Aurich Zanettini Martins @ 2026-11-04 22:25 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, Vincent Donnefort,
	Sebastian Andrzej Siewior, Thomas Gleixner, linux-trace-kernel,
	linux-kernel, Christian Aurich Zanettini Martins,
	syzbot+fbe07bcf949966f3c00f

Creating a tracing instance allocates the buffers of the other CPUs
through trace_rb_cpu_prepare(), which WARNs if the allocation fails.
But __rb_allocate_pages() bails out on purpose when si_mem_available()
is too low or the task gets killed, so a mkdir in instances/ with a
large trace_buf_size is enough to trigger it:

  WARNING: kernel/trace/ring_buffer.c:8094 at trace_rb_cpu_prepare+0xf1/0x100

The same failure for the current CPU, or in ring_buffer_resize(), just
returns -ENOMEM. Use pr_warn() here instead.

Fixes: b32614c03413 ("tracing/rb: Convert to hotplug state machine")
Reported-by: syzbot+fbe07bcf949966f3c00f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6a707c4f.13bfb6d0.1ecdd5.027e.GAE@google.com/
Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
---

Notes:
    Tested in QEMU on 05441d697f7f (4 CPUs, 1G, trace_buf_size=350M): mkdir
    in instances/ WARNs every time before and only prints the message after.
    Same with a mkdir killed during the allocation.

 kernel/trace/ring_buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 1fd28a72e6ee..c018559ad61a 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -8091,8 +8091,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node)
 	buffer->buffers[cpu] =
 		rb_allocate_cpu_buffer(buffer, nr_pages, cpu);
 	if (!buffer->buffers[cpu]) {
-		WARN(1, "failed to allocate ring buffer on CPU %u\n",
-		     cpu);
+		pr_warn("failed to allocate ring buffer on CPU %u\n", cpu);
 		return -ENOMEM;
 	}
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate
  2026-11-04 22:25 [PATCH] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate Christian Aurich Zanettini Martins
@ 2026-11-09  9:29 ` Vincent Donnefort
  0 siblings, 0 replies; 2+ messages in thread
From: Vincent Donnefort @ 2026-11-09  9:29 UTC (permalink / raw)
  To: Christian Aurich Zanettini Martins
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Sebastian Andrzej Siewior, Thomas Gleixner, linux-trace-kernel,
	linux-kernel, syzbot+fbe07bcf949966f3c00f

On Wed, Nov 04, 2026 at 07:25:58PM -0300, Christian Aurich Zanettini Martins wrote:
> Creating a tracing instance allocates the buffers of the other CPUs
> through trace_rb_cpu_prepare(), which WARNs if the allocation fails.
> But __rb_allocate_pages() bails out on purpose when si_mem_available()
> is too low or the task gets killed, so a mkdir in instances/ with a
> large trace_buf_size is enough to trigger it:
> 
>   WARNING: kernel/trace/ring_buffer.c:8094 at trace_rb_cpu_prepare+0xf1/0x100
> 
> The same failure for the current CPU, or in ring_buffer_resize(), just
> returns -ENOMEM. Use pr_warn() here instead.
> 
> Fixes: b32614c03413 ("tracing/rb: Convert to hotplug state machine")
> Reported-by: syzbot+fbe07bcf949966f3c00f@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/all/6a707c4f.13bfb6d0.1ecdd5.027e.GAE@google.com/
> Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
> ---

I do not believe Steven is keen on this change [1]

[1] https://lore.kernel.org/all/20260806174638.6012fa24@gandalf.local.home/

> 
> Notes:
>     Tested in QEMU on 05441d697f7f (4 CPUs, 1G, trace_buf_size=350M): mkdir
>     in instances/ WARNs every time before and only prints the message after.
>     Same with a mkdir killed during the allocation.
> 
>  kernel/trace/ring_buffer.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 1fd28a72e6ee..c018559ad61a 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -8091,8 +8091,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node)
>  	buffer->buffers[cpu] =
>  		rb_allocate_cpu_buffer(buffer, nr_pages, cpu);
>  	if (!buffer->buffers[cpu]) {
> -		WARN(1, "failed to allocate ring buffer on CPU %u\n",
> -		     cpu);
> +		pr_warn("failed to allocate ring buffer on CPU %u\n", cpu);
>  		return -ENOMEM;
>  	}
>  
> -- 
> 2.43.0
> 

-- 
Vincent

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-09  9:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 22:25 [PATCH] ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate Christian Aurich Zanettini Martins
2026-11-09  9:29 ` Vincent Donnefort

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®