Skip to content

Commit f8bbf8b

Browse files
nashuiliangmhiramat
authored andcommitted
tracing/eprobe: Iterate trace_eprobe directly
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/ Link: https://lore.kernel.org/all/20230822022433.262478-1-nashuiliang@gmail.com/ Signed-off-by: Chuang Wang <nashuiliang@gmail.com> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent 8865aea commit f8bbf8b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

kernel/trace/trace_eprobe.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ struct eprobe_data {
4141
struct trace_eprobe *ep;
4242
};
4343

44+
45+
#define for_each_trace_eprobe_tp(ep, _tp) \
46+
list_for_each_entry(ep, trace_probe_probe_list(_tp), tp.list)
47+
4448
static int __trace_eprobe_create(int argc, const char *argv[]);
4549

4650
static void trace_event_probe_cleanup(struct trace_eprobe *ep)
@@ -640,7 +644,7 @@ static int disable_eprobe(struct trace_eprobe *ep,
640644
static int enable_trace_eprobe(struct trace_event_call *call,
641645
struct trace_event_file *file)
642646
{
643-
struct trace_probe *pos, *tp;
647+
struct trace_probe *tp;
644648
struct trace_eprobe *ep;
645649
bool enabled;
646650
int ret = 0;
@@ -662,8 +666,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
662666
if (enabled)
663667
return 0;
664668

665-
list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
666-
ep = container_of(pos, struct trace_eprobe, tp);
669+
for_each_trace_eprobe_tp(ep, tp) {
667670
ret = enable_eprobe(ep, file);
668671
if (ret)
669672
break;
@@ -680,8 +683,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
680683
*/
681684
WARN_ON_ONCE(ret != -ENOMEM);
682685

683-
list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
684-
ep = container_of(pos, struct trace_eprobe, tp);
686+
for_each_trace_eprobe_tp(ep, tp) {
685687
disable_eprobe(ep, file->tr);
686688
if (!--cnt)
687689
break;
@@ -699,7 +701,7 @@ static int enable_trace_eprobe(struct trace_event_call *call,
699701
static int disable_trace_eprobe(struct trace_event_call *call,
700702
struct trace_event_file *file)
701703
{
702-
struct trace_probe *pos, *tp;
704+
struct trace_probe *tp;
703705
struct trace_eprobe *ep;
704706

705707
tp = trace_probe_primary_from_call(call);
@@ -716,10 +718,8 @@ static int disable_trace_eprobe(struct trace_event_call *call,
716718
trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
717719

718720
if (!trace_probe_is_enabled(tp)) {
719-
list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
720-
ep = container_of(pos, struct trace_eprobe, tp);
721+
for_each_trace_eprobe_tp(ep, tp)
721722
disable_eprobe(ep, file->tr);
722-
}
723723
}
724724

725725
out:

0 commit comments

Comments
 (0)