[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250108094051.f6b72d853fd9a67638ec5bc6@kernel.org>
Date: Wed, 8 Jan 2025 09:40:51 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Anil S Keshavamurthy
<anil.s.keshavamurthy@...el.com>, "David S . Miller" <davem@...emloft.net>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Oleg Nesterov
<oleg@...hat.com>, Tzvetomir Stoyanov <tz.stoyanov@...il.com>, Naveen N Rao
<naveen@...nel.org>, Josh Poimboeuf <jpoimboe@...nel.org>, Jason Baron
<jbaron@...mai.com>, Ard Biesheuvel <ardb@...nel.org>,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/5] tracing: Use __free() for kprobe events to
cleanup
On Tue, 7 Jan 2025 10:42:31 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Tue, 7 Jan 2025 20:50:35 +0900
> "Masami Hiramatsu (Google)" <mhiramat@...nel.org> wrote:
>
> > @@ -1898,7 +1899,8 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
> > bool is_return)
> > {
> > enum probe_print_type ptype;
> > - struct trace_kprobe *tk;
> > + struct trace_kprobe *tk __free(free_trace_kprobe) = NULL;
> > + struct trace_probe *tp;
> > int ret;
> > char *event;
> >
> > @@ -1929,19 +1931,16 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
> >
> > ptype = trace_kprobe_is_return(tk) ?
> > PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL;
> > - if (traceprobe_set_print_fmt(&tk->tp, ptype) < 0) {
> > - ret = -ENOMEM;
> > - goto error;
> > - }
> > + if (traceprobe_set_print_fmt(&tk->tp, ptype) < 0)
> > + return ERR_PTR(-ENOMEM);
> >
> > ret = __register_trace_kprobe(tk);
> > if (ret < 0)
> > - goto error;
> > + return ERR_PTR(ret);
> >
> > - return trace_probe_event_call(&tk->tp);
> > -error:
> > - free_trace_kprobe(tk);
> > - return ERR_PTR(ret);
>
>
> > + tp = &tk->tp;
> > + tk = NULL; /* 'tk' is registered successfully, so do not free. */
>
> I wonder if we could change the above to just:
>
> tp = &(no_free_ptr(tk)->tp);
Ah, that's nice idea. Then I can remove 'tp' as;
return trace_probe_event_call(&(no_free_ptr(tk)->tp));
Thanks!
>
> ?
>
> -- Steve
>
> > + return trace_probe_event_call(tp);
> > }
> >
> > void destroy_local_trace_kprobe(struct trace_event_call *event_call)
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists