ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate
Subsystems (2)
PATCH 1/1 ring-buffer: Do not WARN when trace_rb_cpu_prepare() fails to allocate
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.
---
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(-)
kernel/trace/ring_buffer.c +1 -2
@@ -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 ; }
Signature · 1 line
2.43.0
Vincent Donnefort
maintainerQuoted 8 lines · Christian Aurich Zanettini Martins
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 whensi_mem_available()is too low or the task gets killed, so a mkdir in instances/ with a largetrace_buf_sizeis enough to trigger it:WARNING: kernel/trace/ring_buffer.c:8094 at trace_rb_cpu_prepare+0xf1/0x100
Quoted 8 lines
The same failure for the current CPU, or in
ring_buffer_resize(), just returns-ENOMEM. Usepr_warn()here instead.Fixes b32614c03413 ("tracing/rb: Convert to hotplug state machine")Reported-by [email protected]Signed-off-by Christian Aurich Zanettini Martins <[email protected]>---
I do not believe Steven is keen on this change [1]
[1] https://lore.kernel.org/all/[email protected]/
Quoted 26 lines
Notes:
Tested in QEMU on05441d697f7f(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(-)kernel/trace/ring_buffer.c +1
-2@@ -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 ; }Signature · 1 line
2.43.0
Signature · 1 line
Vincent
Thanks Vincent. I took that reply as Steven explaining where the warning comes from, but I may have misread it.
Steven, the same si_mem_available() check fails silently for the current CPU in alloc_buffer(), so whether mkdir WARNs or just returns -ENOMEM depends on which CPU runs out first. If you'd rather keep the WARN I'll drop this.
Em seg., 9 de nov. de 2026 às 06:29, Vincent Donnefort <[email protected]> escreveu:
Quoted 52 lines · Christian Aurich Zanettini Martins
Quoted 8 lines
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 whensi_mem_available()is too low or the task gets killed, so a mkdir in instances/ with a largetrace_buf_sizeis enough to trigger it:WARNING: kernel/trace/ring_buffer.c:8094 at trace_rb_cpu_prepare+0xf1/0x100Quoted 8 lines
The same failure for the current CPU, or in
ring_buffer_resize(), just returns-ENOMEM. Usepr_warn()here instead.Fixes b32614c03413 ("tracing/rb: Convert to hotplug state machine")Reported-by [email protected]Signed-off-by Christian Aurich Zanettini Martins <[email protected]>---
I do not believe Steven is keen on this change [1]
[1] https://lore.kernel.org/all/[email protected]/
Quoted 24 lines
Notes:
Tested in QEMU on05441d697f7f(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(-)kernel/trace/ring_buffer.c +1
-3@@ -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 ; } --Quoted 2 lines
2.43.0
--
Vincent
Steven Rostedt
maintainerQuoted 7 lines · On Mon, 9 Nov 2026 07:38:55 -0300 Christian Aurich Zanettini Martins…
Thanks Vincent. I took that reply as Steven explaining where the warning comes from, but I may have misread it.
Steven, the same
si_mem_available()check fails silently for the current CPU inalloc_buffer(), so whether mkdir WARNs or just returns-ENOMEMdepends on which CPU runs out first. If you'd rather keep the WARN I'll drop this.
Actually, because of the CPU coming on line (not the instances) I pulled it into my test queue. I'm currently traveling so I haven't pushed things up yet. But patchwork has updated the status[1] of this to "Under review" which means it's in the testing process.
-- Steve