* [PATCH] ring-buffer: Fix refcount setting of boot mapped buffers
@ 2024-10-11 20:52 Steven Rostedt
2024-10-12 5:20 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2024-10-11 20:52 UTC (permalink / raw)
To: LKML, Linux Trace Kernel; +Cc: Masami Hiramatsu, Mathieu Desnoyers
From: Steven Rostedt <rostedt@goodmis.org>
A ring buffer which has its buffered mapped at boot up to fixed memory
should not be freed. Other buffers can be. The ref counting setup was
wrong for both. It made the not mapped buffers ref count have zero, and the
boot mapped buffer a ref count of 1. But an normally allocated buffer
should be 1, where it can be removed.
Keep the ref count of a normal boot buffer with its setup ref count (do
not decrement it), and increment the fixed memory boot mapped buffer's ref
count.
Fixes: e645535a954ad ("tracing: Add option to use memmapped memory for trace boot instance")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c01375adc471..5ba40f39c8b5 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -10610,10 +10610,10 @@ __init static void enable_instances(void)
* cannot be deleted by user space, so keep the reference
* to it.
*/
- if (start)
+ if (start) {
tr->flags |= TRACE_ARRAY_FL_BOOT;
- else
- trace_array_put(tr);
+ tr->ref++;
+ }
while ((tok = strsep(&curr_str, ","))) {
early_enable_events(tr, tok, true);
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ring-buffer: Fix refcount setting of boot mapped buffers
2024-10-11 20:52 [PATCH] ring-buffer: Fix refcount setting of boot mapped buffers Steven Rostedt
@ 2024-10-12 5:20 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2024-10-12 5:20 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers
On Fri, 11 Oct 2024 16:52:24 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> A ring buffer which has its buffered mapped at boot up to fixed memory
> should not be freed. Other buffers can be. The ref counting setup was
> wrong for both. It made the not mapped buffers ref count have zero, and the
> boot mapped buffer a ref count of 1. But an normally allocated buffer
> should be 1, where it can be removed.
>
> Keep the ref count of a normal boot buffer with its setup ref count (do
> not decrement it), and increment the fixed memory boot mapped buffer's ref
> count.
>
Looks good to me.
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you,
> Fixes: e645535a954ad ("tracing: Add option to use memmapped memory for trace boot instance")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> kernel/trace/trace.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index c01375adc471..5ba40f39c8b5 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -10610,10 +10610,10 @@ __init static void enable_instances(void)
> * cannot be deleted by user space, so keep the reference
> * to it.
> */
> - if (start)
> + if (start) {
> tr->flags |= TRACE_ARRAY_FL_BOOT;
> - else
> - trace_array_put(tr);
> + tr->ref++;
> + }
>
> while ((tok = strsep(&curr_str, ","))) {
> early_enable_events(tr, tok, true);
> --
> 2.45.2
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-12 5:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 20:52 [PATCH] ring-buffer: Fix refcount setting of boot mapped buffers Steven Rostedt
2024-10-12 5:20 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).