linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check
@ 2020-06-23 23:48 Gaurav Singh
  2020-06-24 12:42 ` Jiri Olsa
  2020-06-24 16:04 ` Adrian Hunter
  0 siblings, 2 replies; 4+ messages in thread
From: Gaurav Singh @ 2020-06-23 23:48 UTC (permalink / raw)
  To: gaurav1086, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Adrian Hunter, Mathieu Poirier,
	Ian Rogers, open list:PERFORMANCE EVENTS SUBSYSTEM

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

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 839ef52c1ac2..8cc87fd2dc6f 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -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) {
-- 
2.17.1


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

* Re: [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check
  2020-06-23 23:48 [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check Gaurav Singh
@ 2020-06-24 12:42 ` Jiri Olsa
  2020-06-24 16:05   ` Adrian Hunter
  2020-06-24 16:04 ` Adrian Hunter
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2020-06-24 12:42 UTC (permalink / raw)
  To: Gaurav Singh
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Adrian Hunter,
	Mathieu Poirier, Ian Rogers,
	open list:PERFORMANCE EVENTS SUBSYSTEM

On Tue, Jun 23, 2020 at 07:48:50PM -0400, Gaurav Singh wrote:
> intel_pt_evsel cannot be NULL here since its already being
> dereferenced above. Remove this redundant check.
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
> ---
>  tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> index 839ef52c1ac2..8cc87fd2dc6f 100644
> --- a/tools/perf/arch/x86/util/intel-pt.c
> +++ b/tools/perf/arch/x86/util/intel-pt.c
> @@ -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

> -	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) {
> -- 
> 2.17.1
> 


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

* Re: [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check
  2020-06-23 23:48 [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check Gaurav Singh
  2020-06-24 12:42 ` Jiri Olsa
@ 2020-06-24 16:04 ` Adrian Hunter
  1 sibling, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2020-06-24 16:04 UTC (permalink / raw)
  To: Gaurav Singh, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Mathieu Poirier, Ian Rogers,
	open list:PERFORMANCE EVENTS SUBSYSTEM

On 24/06/20 2:48 am, Gaurav Singh wrote:
> intel_pt_evsel cannot be NULL here since its already being
> dereferenced above. Remove this redundant check.
> 
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
> index 839ef52c1ac2..8cc87fd2dc6f 100644
> --- a/tools/perf/arch/x86/util/intel-pt.c
> +++ b/tools/perf/arch/x86/util/intel-pt.c
> @@ -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) {
> 


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

* Re: [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check
  2020-06-24 12:42 ` Jiri Olsa
@ 2020-06-24 16:05   ` Adrian Hunter
  0 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2020-06-24 16:05 UTC (permalink / raw)
  To: Jiri Olsa, Gaurav Singh
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Mathieu Poirier,
	Ian Rogers, open list:PERFORMANCE EVENTS SUBSYSTEM

On 24/06/20 3:42 pm, Jiri Olsa wrote:
> On Tue, Jun 23, 2020 at 07:48:50PM -0400, Gaurav Singh wrote:
>> intel_pt_evsel cannot be NULL here since its already being
>> dereferenced above. Remove this redundant check.
>>
>> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
>> ---
>>  tools/perf/arch/x86/util/intel-pt.c | 24 +++++++++++-------------
>>  1 file changed, 11 insertions(+), 13 deletions(-)
>>
>> diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
>> index 839ef52c1ac2..8cc87fd2dc6f 100644
>> --- a/tools/perf/arch/x86/util/intel-pt.c
>> +++ b/tools/perf/arch/x86/util/intel-pt.c
>> @@ -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.

> 
> thanks,
> jirka
> 
>> -	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) {
>> -- 
>> 2.17.1
>>
> 


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

end of thread, other threads:[~2020-06-24 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 23:48 [PATCH] [perf] intel_pt_recording_options: Remove redundant intel_pt_evsel null check Gaurav Singh
2020-06-24 12:42 ` Jiri Olsa
2020-06-24 16:05   ` Adrian Hunter
2020-06-24 16:04 ` Adrian Hunter

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