mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
	Naveen N Rao <naveen@kernel.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Jason Baron <jbaron@akamai.com>, Ard Biesheuvel <ardb@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/5] tracing: Use __free() for kprobe events to cleanup
Date: Tue, 7 Jan 2025 10:42:31 -0500	[thread overview]
Message-ID: <20250107104231.06eeaca8@gandalf.local.home> (raw)
In-Reply-To: <173625063552.1375434.16867809967348842161.stgit@devnote2>

On Tue,  7 Jan 2025 20:50:35 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.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);

?

-- Steve

> +	return trace_probe_event_call(tp);
>  }
>  
>  void destroy_local_trace_kprobe(struct trace_event_call *event_call)


  reply	other threads:[~2025-01-07 15:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07 11:50 [PATCH v3 0/5] tracing/probes: Cleanup with guard and __free for kprobe and fprobe Masami Hiramatsu (Google)
2025-01-07 11:50 ` [PATCH v3 1/5] tracing/kprobes: Fix to free objects when failed to copy a symbol Masami Hiramatsu (Google)
2025-01-07 11:50 ` [PATCH v3 2/5] tracing: Use __free() in trace_probe for cleanup Masami Hiramatsu (Google)
2025-01-07 15:36   ` Steven Rostedt
2025-01-08  0:38     ` Masami Hiramatsu
2025-01-08  1:34       ` Steven Rostedt
2025-01-08  2:03         ` Masami Hiramatsu
2025-01-07 11:50 ` [PATCH v3 3/5] tracing: Use __free() for kprobe events to cleanup Masami Hiramatsu (Google)
2025-01-07 15:42   ` Steven Rostedt [this message]
2025-01-08  0:40     ` Masami Hiramatsu
2025-01-07 11:50 ` [PATCH v3 4/5] tracing/kprobes: Simplify __trace_kprobe_create() by removing gotos Masami Hiramatsu (Google)
2025-01-07 11:50 ` [PATCH v3 5/5] tracing: Adopt __free() and guard() for trace_fprobe.c Masami Hiramatsu (Google)
2025-01-07 11:53 ` [PATCH v3 0/5] tracing/probes: Cleanup with guard and __free for kprobe and fprobe Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250107104231.06eeaca8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=naveen@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®