diff mbox series

[v5,06/15] ring-buffer: Clear pages on error in ring_buffer_subbuf_order_set() failure

Message ID 20231219185629.179352802@goodmis.org (mailing list archive)
State Accepted
Commit 22887dfba0633c09444562722f0cf68f61ec9a50
Headers show
Series ring-buffer/tracing: Allow ring buffer to have bigger sub buffers | expand

Commit Message

Steven Rostedt Dec. 19, 2023, 6:54 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

On failure to allocate ring buffer pages, the pointer to the CPU buffer
pages is freed, but the pages that were allocated previously were not.
Make sure they are freed too.

Fixes: TBD ("tracing: Set new size of the ring buffer sub page")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/ring_buffer.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Masami Hiramatsu (Google) Dec. 20, 2023, 4:23 p.m. UTC | #1
On Tue, 19 Dec 2023 13:54:20 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> On failure to allocate ring buffer pages, the pointer to the CPU buffer
> pages is freed, but the pages that were allocated previously were not.
> Make sure they are freed too.
> 
> Fixes: TBD ("tracing: Set new size of the ring buffer sub page")

Do you merge this fix to the original one in the same series later?
I think it is better to merge it for git bisect.

Thank you,

> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  kernel/trace/ring_buffer.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index c2afcf98ea91..3c11e8e811ed 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -5927,6 +5927,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
>  	for_each_buffer_cpu(buffer, cpu) {
>  		if (!cpu_buffers[cpu])
>  			continue;
> +		rb_free_cpu_buffer(cpu_buffers[cpu]);
>  		kfree(cpu_buffers[cpu]);
>  	}
>  	kfree(cpu_buffers);
> -- 
> 2.42.0
> 
>
Steven Rostedt Dec. 20, 2023, 4:30 p.m. UTC | #2
On Thu, 21 Dec 2023 01:23:14 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Tue, 19 Dec 2023 13:54:20 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> > 
> > On failure to allocate ring buffer pages, the pointer to the CPU buffer
> > pages is freed, but the pages that were allocated previously were not.
> > Make sure they are freed too.
> > 
> > Fixes: TBD ("tracing: Set new size of the ring buffer sub page")  
> 
> Do you merge this fix to the original one in the same series later?
> I think it is better to merge it for git bisect.

It only fixes the new functionality. If a git bisect gets here for that,
then we know the issue already. But it shouldn't break bisect for things
that happened before this change.

The reason I'm not merging this with the other patch is because the
original patch is from Tzvetomir, who isn't working on this anymore. I want
to keep his patches untouched, and anything I do is on top of it.

-- Steve
diff mbox series

Patch

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index c2afcf98ea91..3c11e8e811ed 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5927,6 +5927,7 @@  int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
 	for_each_buffer_cpu(buffer, cpu) {
 		if (!cpu_buffers[cpu])
 			continue;
+		rb_free_cpu_buffer(cpu_buffers[cpu]);
 		kfree(cpu_buffers[cpu]);
 	}
 	kfree(cpu_buffers);