Skip to contentSkip to conversation

tracing: Simplify conditional compilation code in tracing_set_tracer()

PATCH Superseded sunliming 3 participants 3 messages Jun 2, 2022 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

sunliming

author
#0 lore raw

PATCH 1/1 tracing: Simplify conditional compilation code in tracing_set_tracer()

Two conditional compilation directives "#ifdef CONFIG_TRACER_SNAPSHOT" are used consecutively, and no other code in between. Simplify conditional the compilation code and only use one "#ifdef CONFIG_TRACER_SNAPSHOT".

---
 kernel/trace/trace.c | 2 --
 1 file changed, 2 deletions(-)
kernel/trace/trace.c +0 -2
index f400800bc910..dc959e339512 100644
@@ -6430,9 +6430,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 		synchronize_rcu();
 		free_snapshot(tr);
 	}
-#endif
 
-#ifdef CONFIG_TRACER_MAX_TRACE
 	if (t->use_max_tr && !had_max_tr) {
 		ret = tracing_alloc_snapshot_instance(tr);
 		if (ret < 0)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 3 lines · On Thu, 2 Jun 2022 10:24:04 +0800 sunliming <[email protected]> wrote:

Two conditional compilation directives "#ifdef CONFIG_TRACER_SNAPSHOT" are used consecutively, and no other code in between. Simplify conditional the compilation code and only use one "#ifdef CONFIG_TRACER_SNAPSHOT".

I think you mean CONFIG_TRACER_MAX_TRACE here.

-- Steve

Quoted 20 lines
---
 kernel/trace/trace.c | 2 --
 1 file changed, 2 deletions(-)
kernel/trace/trace.c +0 -2
index f400800bc910..dc959e339512 100644
@@ -6430,9 +6430,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 		synchronize_rcu();
 		free_snapshot(tr);
 	}
-#endif
 
-#ifdef CONFIG_TRACER_MAX_TRACE
 	if (t->use_max_tr && !had_max_tr) {
 		ret = tracing_alloc_snapshot_instance(tr);
 		if (ret < 0)
#2 lore raw
Quoted 28 lines · Steven Rostedt <[email protected]> 于2022年6月2日周四 20:26写道:
Quoted 3 lines · On Thu, 2 Jun 2022 10:24:04 +0800 sunliming <[email protected]> wrote:

Two conditional compilation directives "#ifdef CONFIG_TRACER_SNAPSHOT" are used consecutively, and no other code in between. Simplify conditional the compilation code and only use one "#ifdef CONFIG_TRACER_SNAPSHOT".

I think you mean CONFIG_TRACER_MAX_TRACE here.

-- Steve

Quoted 16 lines
---
 kernel/trace/trace.c | 2 --
 1 file changed, 2 deletions(-)
kernel/trace/trace.c +0 -1
index f400800bc910..dc959e339512 100644
@@ -6430,9 +6430,7 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
              synchronize_rcu();
              free_snapshot(tr);
      }
-#endif
 
Quoted 5 lines

kernel/trace/trace.c int tracing_set_tracer(struct trace_array *tr, const char *buf) · line 6436

Quoted 4 lines
kernel/trace/trace.c +0 -1
-#ifdef CONFIG_TRACER_MAX_TRACE
      if (t->use_max_tr && !had_max_tr) {
              ret = tracing_alloc_snapshot_instance(tr);
              if (ret < 0)

Yes, you are right. I am sorry about this low-level mistakes.