linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Chuang Wang <nashuiliang@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tracing/eprobe: Iterate trace_eprobe directly
Date: Tue, 22 Aug 2023 20:43:47 +0900	[thread overview]
Message-ID: <20230822204347.8b90a8507bde3343bb1ca264@kernel.org> (raw)
In-Reply-To: <20230822022433.262478-1-nashuiliang@gmail.com>

On Tue, 22 Aug 2023 10:24:33 +0800
Chuang Wang <nashuiliang@gmail.com> wrote:

> Refer to the description in [1], we can skip "container_of()" following
> "list_for_each_entry()" by using "list_for_each_entry()" with
> "struct trace_eprobe" and "tp.list".
> 
> Also, this patch defines "for_each_trace_eprobe_tp" to simplify the code
> of the same logic.
> 
> [1] https://lore.kernel.org/all/CAHk-=wjakjw6-rDzDDBsuMoDCqd+9ogifR_EE1F0K-jYek1CdA@mail.gmail.com/
> 
> Signed-off-by: Chuang Wang <nashuiliang@gmail.com>

Thanks, this looks good to me.

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

> ---
> v2 -> v3:
> - use "for_each_trace_eprobe_tp" instead of "for_each_trace_eprobe_on_trace_probe"
> 
> v1 -> v2:
> - add "for_each_trace_eprobe_on_trace_probe" as suggested by Masami
> 
> v0 -> v1:
> - remove "Fixes" in the commit information.
> 
>  kernel/trace/trace_eprobe.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index a0a704ba27db..6a024b5912e2 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -41,6 +41,10 @@ struct eprobe_data {
>  	struct trace_eprobe	*ep;
>  };
>  
> +
> +#define for_each_trace_eprobe_tp(ep, _tp) \
> +	list_for_each_entry(ep, trace_probe_probe_list(_tp), tp.list)
> +
>  static int __trace_eprobe_create(int argc, const char *argv[]);
>  
>  static void trace_event_probe_cleanup(struct trace_eprobe *ep)
> @@ -640,7 +644,7 @@ static int disable_eprobe(struct trace_eprobe *ep,
>  static int enable_trace_eprobe(struct trace_event_call *call,
>  			       struct trace_event_file *file)
>  {
> -	struct trace_probe *pos, *tp;
> +	struct trace_probe *tp;
>  	struct trace_eprobe *ep;
>  	bool enabled;
>  	int ret = 0;
> @@ -662,8 +666,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
>  	if (enabled)
>  		return 0;
>  
> -	list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
> -		ep = container_of(pos, struct trace_eprobe, tp);
> +	for_each_trace_eprobe_tp(ep, tp) {
>  		ret = enable_eprobe(ep, file);
>  		if (ret)
>  			break;
> @@ -680,8 +683,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
>  			 */
>  			WARN_ON_ONCE(ret != -ENOMEM);
>  
> -			list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
> -				ep = container_of(pos, struct trace_eprobe, tp);
> +			for_each_trace_eprobe_tp(ep, tp) {
>  				disable_eprobe(ep, file->tr);
>  				if (!--cnt)
>  					break;
> @@ -699,7 +701,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
>  static int disable_trace_eprobe(struct trace_event_call *call,
>  				struct trace_event_file *file)
>  {
> -	struct trace_probe *pos, *tp;
> +	struct trace_probe *tp;
>  	struct trace_eprobe *ep;
>  
>  	tp = trace_probe_primary_from_call(call);
> @@ -716,10 +718,8 @@ static int disable_trace_eprobe(struct trace_event_call *call,
>  		trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
>  
>  	if (!trace_probe_is_enabled(tp)) {
> -		list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
> -			ep = container_of(pos, struct trace_eprobe, tp);
> +		for_each_trace_eprobe_tp(ep, tp)
>  			disable_eprobe(ep, file->tr);
> -		}
>  	}
>  
>   out:
> -- 
> 2.39.2
> 


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

      reply	other threads:[~2023-08-22 11:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22  2:24 [PATCH v3] tracing/eprobe: Iterate trace_eprobe directly Chuang Wang
2023-08-22 11:43 ` 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=20230822204347.8b90a8507bde3343bb1ca264@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=nashuiliang@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;
as well as URLs for NNTP newsgroup(s).