linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
@ 2023-08-11  8:12 Chuang Wang
  2023-08-11 11:48 ` Masami Hiramatsu
  2023-08-11 19:45 ` Steven Rostedt
  0 siblings, 2 replies; 7+ messages in thread
From: Chuang Wang @ 2023-08-11  8:12 UTC (permalink / raw)
  Cc: Chuang Wang, Steven Rostedt, Masami Hiramatsu, linux-kernel,
	linux-trace-kernel

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_on_trace_probe" 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>
---
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..b7c6179f8b7f 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_on_trace_probe(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_on_trace_probe(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_on_trace_probe(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_on_trace_probe(ep, tp)
 			disable_eprobe(ep, file->tr);
-		}
 	}
 
  out:
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-11  8:12 [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly Chuang Wang
@ 2023-08-11 11:48 ` Masami Hiramatsu
  2023-08-11 19:45 ` Steven Rostedt
  1 sibling, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2023-08-11 11:48 UTC (permalink / raw)
  To: Chuang Wang
  Cc: Steven Rostedt, Masami Hiramatsu, linux-kernel,
	linux-trace-kernel

On Fri, 11 Aug 2023 16:12:39 +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_on_trace_probe" to
> simplify the code of the same logic.
> 
> [1] https://lore.kernel.org/all/CAHk-=wjakjw6-rDzDDBsuMoDCqd+9ogifR_EE1F0K-jYek1CdA@mail.gmail.com/
> 

This looks good to me.

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

Thanks!

> Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
> ---
> 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..b7c6179f8b7f 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_on_trace_probe(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_on_trace_probe(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_on_trace_probe(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_on_trace_probe(ep, tp)
>  			disable_eprobe(ep, file->tr);
> -		}
>  	}
>  
>   out:
> -- 
> 2.39.2
> 


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-11  8:12 [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly Chuang Wang
  2023-08-11 11:48 ` Masami Hiramatsu
@ 2023-08-11 19:45 ` Steven Rostedt
  2023-08-12  5:20   ` Masami Hiramatsu
  1 sibling, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2023-08-11 19:45 UTC (permalink / raw)
  To: Chuang Wang; +Cc: Masami Hiramatsu, linux-kernel, linux-trace-kernel

On Fri, 11 Aug 2023 16:12:39 +0800
Chuang Wang <nashuiliang@gmail.com> wrote:

> +
> +#define for_each_trace_eprobe_on_trace_probe(ep, _tp) \
> +	list_for_each_entry(ep, trace_probe_probe_list(_tp), tp.list)
> +

As I replied to the other patch, but after this one was sent (sorry, I was
hyperfocused on my work the last couple of days and was not reading email,
so my INBOX is a bit full). I really hate the verbosity of that name.

At a minimum, let's call it:

  for_each_trace_point_eprobe()

-- Steve

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-11 19:45 ` Steven Rostedt
@ 2023-08-12  5:20   ` Masami Hiramatsu
  2023-08-16 20:08     ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2023-08-12  5:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Chuang Wang, Masami Hiramatsu, linux-kernel, linux-trace-kernel

On Fri, 11 Aug 2023 15:45:23 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Fri, 11 Aug 2023 16:12:39 +0800
> Chuang Wang <nashuiliang@gmail.com> wrote:
> 
> > +
> > +#define for_each_trace_eprobe_on_trace_probe(ep, _tp) \
> > +	list_for_each_entry(ep, trace_probe_probe_list(_tp), tp.list)
> > +
> 
> As I replied to the other patch, but after this one was sent (sorry, I was
> hyperfocused on my work the last couple of days and was not reading email,
> so my INBOX is a bit full). I really hate the verbosity of that name.
> 
> At a minimum, let's call it:
> 
>   for_each_trace_point_eprobe()

OK, what about "for_each_trace_eprobe_on()"? I would like to clarify

- what type is returned
- not all trace_eprobes, but only on the trace_probe.

Thank you,

> 
> -- Steve


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-12  5:20   ` Masami Hiramatsu
@ 2023-08-16 20:08     ` Steven Rostedt
  2023-08-18 11:02       ` Masami Hiramatsu
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2023-08-16 20:08 UTC (permalink / raw)
  To: Masami Hiramatsu (Google); +Cc: Chuang Wang, linux-kernel, linux-trace-kernel

On Sat, 12 Aug 2023 14:20:19 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> > At a minimum, let's call it:
> > 
> >   for_each_trace_point_eprobe()  
> 
> OK, what about "for_each_trace_eprobe_on()"? I would like to clarify
> 
> - what type is returned
> - not all trace_eprobes, but only on the trace_probe.
> 
> Thank you,

 for_each_trace_eprobe_tp() or for_each_trace_tp_eprobe() ?

As it only works for a trace_probe.

-- Steve

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-16 20:08     ` Steven Rostedt
@ 2023-08-18 11:02       ` Masami Hiramatsu
  2023-08-18 11:42         ` chuang
  0 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2023-08-18 11:02 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Chuang Wang, linux-kernel, linux-trace-kernel

On Wed, 16 Aug 2023 16:08:50 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Sat, 12 Aug 2023 14:20:19 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> 
> > > At a minimum, let's call it:
> > > 
> > >   for_each_trace_point_eprobe()  
> > 
> > OK, what about "for_each_trace_eprobe_on()"? I would like to clarify
> > 
> > - what type is returned
> > - not all trace_eprobes, but only on the trace_probe.
> > 
> > Thank you,
> 
>  for_each_trace_eprobe_tp() or for_each_trace_tp_eprobe() ?

for_each_trace_eprobe_tp() is OK for me.

Thanks!

> 
> As it only works for a trace_probe.
> 
> -- Steve


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly
  2023-08-18 11:02       ` Masami Hiramatsu
@ 2023-08-18 11:42         ` chuang
  0 siblings, 0 replies; 7+ messages in thread
From: chuang @ 2023-08-18 11:42 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Steven Rostedt, linux-kernel, linux-trace-kernel

OK, I will submit a new patch using "for_each_trace_eprobe_tp".

On Fri, Aug 18, 2023 at 7:03 PM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> On Wed, 16 Aug 2023 16:08:50 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > On Sat, 12 Aug 2023 14:20:19 +0900
> > Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> >
> > > > At a minimum, let's call it:
> > > >
> > > >   for_each_trace_point_eprobe()
> > >
> > > OK, what about "for_each_trace_eprobe_on()"? I would like to clarify
> > >
> > > - what type is returned
> > > - not all trace_eprobes, but only on the trace_probe.
> > >
> > > Thank you,
> >
> >  for_each_trace_eprobe_tp() or for_each_trace_tp_eprobe() ?
>
> for_each_trace_eprobe_tp() is OK for me.
>
> Thanks!
>
> >
> > As it only works for a trace_probe.
> >
> > -- Steve
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-18 11:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11  8:12 [PATCH v2] tracing/eprobe: Iterate trace_eprobe directly Chuang Wang
2023-08-11 11:48 ` Masami Hiramatsu
2023-08-11 19:45 ` Steven Rostedt
2023-08-12  5:20   ` Masami Hiramatsu
2023-08-16 20:08     ` Steven Rostedt
2023-08-18 11:02       ` Masami Hiramatsu
2023-08-18 11:42         ` chuang

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).