Skip to contentSkip to conversation

intel_pt_recording_options: Remove redundant intel_pt_evsel null check

PATCH In review Gaurav Singh 3 participants 4 messages Jun 23, 2020 – Jun 24, 2020 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_pt_recording_options: Remove redundant intel_pt_evsel null check

intel_pt_evsel cannot be NULL here since its already being dereferenced above. Remove this redundant check.

---
 tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
tools/perf/arch/x86/util/intel-pt.c +11 -13
index 839ef52c1ac2..8cc87fd2dc6f 100644
@@ -836,19 +836,17 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 		}
 	}
 
-	if (intel_pt_evsel) {
-		/*
-		 * To obtain the auxtrace buffer file descriptor, the auxtrace
-		 * event must come first.
-		 */
-		perf_evlist__to_front(evlist, intel_pt_evsel);
-		/*
-		 * In the case of per-cpu mmaps, we need the CPU on the
-		 * AUX event.
-		 */
-		if (!perf_cpu_map__empty(cpus))
-			evsel__set_sample_bit(intel_pt_evsel, CPU);
-	}
+	/*
+	 * To obtain the auxtrace buffer file descriptor, the auxtrace
+	 * event must come first.
+	 */
+	perf_evlist__to_front(evlist, intel_pt_evsel);
+	/*
+	 * In the case of per-cpu mmaps, we need the CPU on the
+	 * AUX event.
+	 */
+	if (!perf_cpu_map__empty(cpus))
+		evsel__set_sample_bit(intel_pt_evsel, CPU);
 
 	/* Add dummy event to keep tracking */
 	if (opts->full_auxtrace) {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · Gaurav Singh

intel_pt_evsel cannot be NULL here since its already being dereferenced above. Remove this redundant check.

---
 tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
tools/perf/arch/x86/util/intel-pt.c +0 -0
index 839ef52c1ac2..8cc87fd2dc6f 100644

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct auxtrace_record *itr, · line 838

Quoted 3 lines
tools/perf/arch/x86/util/intel-pt.c +0 -0
@@ -836,19 +836,17 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 		}
 	}
 

I wonder we sould put check before that above usage of intel_pt_evsel, because there's no check for that.. but yes, if intel_pt_evsel is NULL it will fail earlier.. Adrian?

thanks,
jirka

Quoted 30 lines
tools/perf/arch/x86/util/intel-pt.c +11 -13
-	if (intel_pt_evsel) {
-		/*
-		 * To obtain the auxtrace buffer file descriptor, the auxtrace
-		 * event must come first.
-		 */
-		perf_evlist__to_front(evlist, intel_pt_evsel);
-		/*
-		 * In the case of per-cpu mmaps, we need the CPU on the
-		 * AUX event.
-		 */
-		if (!perf_cpu_map__empty(cpus))
-			evsel__set_sample_bit(intel_pt_evsel, CPU);
-	}
+	/*
+	 * To obtain the auxtrace buffer file descriptor, the auxtrace
+	 * event must come first.
+	 */
+	perf_evlist__to_front(evlist, intel_pt_evsel);
+	/*
+	 * In the case of per-cpu mmaps, we need the CPU on the
+	 * AUX event.
+	 */
+	if (!perf_cpu_map__empty(cpus))
+		evsel__set_sample_bit(intel_pt_evsel, CPU);
 
 	/* Add dummy event to keep tracking */
 	if (opts->full_auxtrace) {
Signature · 1 line
2.17.1
reviewer
#2 lore raw
Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Gaurav Singh

intel_pt_evsel cannot be NULL here since its already being dereferenced above. Remove this redundant check.

---
 tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
Quoted 12 lines

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct auxtrace_record *itr, · line 838

Quoted 8 lines
tools/perf/arch/x86/util/intel-pt.c +0 -0
index 839ef52c1ac2..8cc87fd2dc6f 100644
@@ -836,19 +836,17 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 		}
 	}
 

I wonder we sould put check before that above usage of intel_pt_evsel, because there's no check for that.. but yes, if intel_pt_evsel is NULL it will fail earlier.. Adrian?

The code was written when sampling-mode did not require an intel_pt_evsel. Now it does, so intel_pt_evsel will not be NULL. I think it is OK as is.

Quoted 35 lines

thanks,
jirka

Quoted 30 lines
tools/perf/arch/x86/util/intel-pt.c +11 -13
-	if (intel_pt_evsel) {
-		/*
-		 * To obtain the auxtrace buffer file descriptor, the auxtrace
-		 * event must come first.
-		 */
-		perf_evlist__to_front(evlist, intel_pt_evsel);
-		/*
-		 * In the case of per-cpu mmaps, we need the CPU on the
-		 * AUX event.
-		 */
-		if (!perf_cpu_map__empty(cpus))
-			evsel__set_sample_bit(intel_pt_evsel, CPU);
-	}
+	/*
+	 * To obtain the auxtrace buffer file descriptor, the auxtrace
+	 * event must come first.
+	 */
+	perf_evlist__to_front(evlist, intel_pt_evsel);
+	/*
+	 * In the case of per-cpu mmaps, we need the CPU on the
+	 * AUX event.
+	 */
+	if (!perf_cpu_map__empty(cpus))
+		evsel__set_sample_bit(intel_pt_evsel, CPU);
 
 	/* Add dummy event to keep tracking */
 	if (opts->full_auxtrace) {
Signature · 1 line
2.17.1
reviewer Acked-by on v1 1/1
#3 lore raw
In reply to Gaurav Singh
Quoted 4 lines · Gaurav Singh

intel_pt_evsel cannot be NULL here since its already being dereferenced above. Remove this redundant check.

Quoted 40 lines
---
 tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
tools/perf/arch/x86/util/intel-pt.c +11 -13
index 839ef52c1ac2..8cc87fd2dc6f 100644
@@ -836,19 +836,17 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 		}
 	}
 
-	if (intel_pt_evsel) {
-		/*
-		 * To obtain the auxtrace buffer file descriptor, the auxtrace
-		 * event must come first.
-		 */
-		perf_evlist__to_front(evlist, intel_pt_evsel);
-		/*
-		 * In the case of per-cpu mmaps, we need the CPU on the
-		 * AUX event.
-		 */
-		if (!perf_cpu_map__empty(cpus))
-			evsel__set_sample_bit(intel_pt_evsel, CPU);
-	}
+	/*
+	 * To obtain the auxtrace buffer file descriptor, the auxtrace
+	 * event must come first.
+	 */
+	perf_evlist__to_front(evlist, intel_pt_evsel);
+	/*
+	 * In the case of per-cpu mmaps, we need the CPU on the
+	 * AUX event.
+	 */
+	if (!perf_cpu_map__empty(cpus))
+		evsel__set_sample_bit(intel_pt_evsel, CPU);
 
 	/* Add dummy event to keep tracking */
 	if (opts->full_auxtrace) {