Re: [RFC PATCH v2 3/3] tracing: Freeable reserved ring buffer

Steven Rostedt
2025-02-11T14:57:27Z

On Tue, 11 Feb 2025 10:41:22 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Mon, 10 Feb 2025 19:13:50 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > On Tue, 11 Feb 2025 00:44:17 +0900
> > "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> >
> > > @@ -9857,8 +9861,10 @@ static int __remove_instance(struct trace_array *tr)
> > > int i;
> > >
> > > /* Reference counter for a newly created trace array = 1. */
> > > - if (tr->ref > 1 || (tr->current_trace && tr->trace_ref))
> > > + if (tr->ref > 1 || (tr->current_trace && tr->trace_ref)) {
> > > + pr_info("Instance is busy: ref %d trace_ref %d\n", tr->ref, tr->trace_ref);
> >
> > I don't think we need the print. The function will error with -EBUSY
> > letting the user know that it is busy. This is a very common error, where I
> > found that I had a program that didn't completely die, and still had a file
> > descriptor open on an instance, and when I go to remove it, I get:
> >
> > # cd /sys/kernel/tracing/
> > # mkdir instances/foo
> > # bash 5< instances/foo/events/enable
> > # rmdir instances/foo
> > rmdir: failed to remove 'instances/foo': Device or resource busy
> > # exit
> > # rmdir instances/foo
> > #
> >
> > If you only have it for debugging that is fine, but we should remove it
> > before we accept it.
>
> Oops, that is my debug code. I missed to remove that! Sorry for confusion.

Heh, that's why I use "printk()" and not the "pr_*()" functions. Since I
don't usually have "printk()" in the normal code but use the "pr_*()"
functions there, it makes it easy for me to find the debug statements I put
into my code while I develop it.

-- Steve