Linux Trace Kernel
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org (open list:TRACING),
	linux-hardening@vger.kernel.org (open list:KERNEL HARDENING (not
	covered by other areas):Keyword:\b__counted_by(_le|_be|_ptr)?\b)
Subject: Re: [PATCH] tracing: Use flexible array for entry fetch code
Date: Thu, 21 May 2026 12:09:47 +0900	[thread overview]
Message-ID: <20260521120947.08f00bd4d7445bc6abc98ce0@kernel.org> (raw)
In-Reply-To: <20260520215817.16560-1-rosenp@gmail.com>

On Wed, 20 May 2026 14:58:17 -0700
Rosen Penev <rosenp@gmail.com> wrote:

> Store probe entry fetch instructions in the probe_entry_arg
> allocation instead of allocating a separate instruction array.
> 
> This keeps the entry fetch code tied to the entry argument lifetime while
> leaving regular probe_arg instruction arrays separately allocated and
> freed.
> 

Thanks, this looks good to me.

> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  kernel/trace/trace_probe.c | 8 +-------
>  kernel/trace/trace_probe.h | 2 +-
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index e0d3a0da26af..39f040c863e8 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -838,15 +838,10 @@ static int __store_entry_arg(struct trace_probe *tp, int argnum)
>  	int i, offset, last_offset = 0;
>  
>  	if (!earg) {
> -		earg = kzalloc_obj(*tp->entry_arg);
> +		earg = kzalloc_flex(*earg, code, 2 * tp->nr_args + 1);
>  		if (!earg)
>  			return -ENOMEM;
>  		earg->size = 2 * tp->nr_args + 1;
> -		earg->code = kzalloc_objs(struct fetch_insn, earg->size);
> -		if (!earg->code) {
> -			kfree(earg);
> -			return -ENOMEM;
> -		}
>  		/* Fill the code buffer with 'end' to simplify it */
>  		for (i = 0; i < earg->size; i++)
>  			earg->code[i].op = FETCH_OP_END;
> @@ -2051,7 +2046,6 @@ void trace_probe_cleanup(struct trace_probe *tp)
>  		traceprobe_free_probe_arg(&tp->args[i]);
>  
>  	if (tp->entry_arg) {
> -		kfree(tp->entry_arg->code);
>  		kfree(tp->entry_arg);
>  		tp->entry_arg = NULL;
>  	}
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index 262d8707a3df..1076f1df347b 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -238,8 +238,8 @@ struct probe_arg {
>  };
>  
>  struct probe_entry_arg {
> -	struct fetch_insn	*code;
>  	unsigned int		size;	/* The entry data size */
> +	struct fetch_insn	code[] __counted_by(size);
>  };
>  
>  struct trace_uprobe_filter {
> -- 
> 2.54.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2026-05-21  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 21:58 [PATCH] tracing: Use flexible array for entry fetch code Rosen Penev
2026-05-21  3:09 ` Masami Hiramatsu [this message]

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=20260521120947.08f00bd4d7445bc6abc98ce0@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=rosenp@gmail.com \
    --cc=rostedt@goodmis.org \
    /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