linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
@ 2025-08-04 11:06 Gautam Menghani
  2025-08-04 12:08 ` Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gautam Menghani @ 2025-08-04 11:06 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang
  Cc: Gautam Menghani, linux-perf-users, linux-kernel

Since commit eead8a011477 ("libperf threadmap: Don't segv for index 0 for the
NULL 'struct perf_thread_map' pointer"), perf_thread_map__pid() can
check for a NULL map and return -1 if idx is 0. Cleanup
auxtrace_mmap_params__set_idx() and remove the redundant NULL check.

No functional change intended.

Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
---
 tools/perf/util/auxtrace.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index ebd32f1b8f12..5e437133c753 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
 
 	if (per_cpu) {
 		mp->cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
-		if (evlist->core.threads)
-			mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
-		else
-			mp->tid = -1;
+		mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
 	} else {
 		mp->cpu.cpu = -1;
 		mp->tid = perf_thread_map__pid(evlist->core.threads, idx);
-- 
2.49.0


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

* Re: [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
  2025-08-04 11:06 [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx() Gautam Menghani
@ 2025-08-04 12:08 ` Adrian Hunter
  2025-08-08 11:14 ` Amit Machhiwal
  2025-08-10 16:08 ` Aditya Bodkhe
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2025-08-04 12:08 UTC (permalink / raw)
  To: Gautam Menghani, peterz, mingo, acme, namhyung, mark.rutland,
	alexander.shishkin, jolsa, irogers, kan.liang
  Cc: linux-perf-users, linux-kernel

On 04/08/2025 14:06, Gautam Menghani wrote:
> Since commit eead8a011477 ("libperf threadmap: Don't segv for index 0 for the
> NULL 'struct perf_thread_map' pointer"), perf_thread_map__pid() can
> check for a NULL map and return -1 if idx is 0. Cleanup
> auxtrace_mmap_params__set_idx() and remove the redundant NULL check.
> 
> No functional change intended.
> 
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>

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

> ---
>  tools/perf/util/auxtrace.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index ebd32f1b8f12..5e437133c753 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
>  
>  	if (per_cpu) {
>  		mp->cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
> -		if (evlist->core.threads)
> -			mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
> -		else
> -			mp->tid = -1;
> +		mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
>  	} else {
>  		mp->cpu.cpu = -1;
>  		mp->tid = perf_thread_map__pid(evlist->core.threads, idx);


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

* Re: [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
  2025-08-04 11:06 [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx() Gautam Menghani
  2025-08-04 12:08 ` Adrian Hunter
@ 2025-08-08 11:14 ` Amit Machhiwal
  2025-08-10 16:08 ` Aditya Bodkhe
  2 siblings, 0 replies; 4+ messages in thread
From: Amit Machhiwal @ 2025-08-08 11:14 UTC (permalink / raw)
  To: Gautam Menghani
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
	linux-kernel

On 2025/08/04 04:36 PM, Gautam Menghani wrote:
> Since commit eead8a011477 ("libperf threadmap: Don't segv for index 0 for the
> NULL 'struct perf_thread_map' pointer"), perf_thread_map__pid() can
> check for a NULL map and return -1 if idx is 0. Cleanup
> auxtrace_mmap_params__set_idx() and remove the redundant NULL check.
> 
> No functional change intended.
> 
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>

LGTM.

Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>

Regards,
Amit

> ---
>  tools/perf/util/auxtrace.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index ebd32f1b8f12..5e437133c753 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
>  
>  	if (per_cpu) {
>  		mp->cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
> -		if (evlist->core.threads)
> -			mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
> -		else
> -			mp->tid = -1;
> +		mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
>  	} else {
>  		mp->cpu.cpu = -1;
>  		mp->tid = perf_thread_map__pid(evlist->core.threads, idx);
> -- 
> 2.49.0
> 

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

* Re: [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx()
  2025-08-04 11:06 [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx() Gautam Menghani
  2025-08-04 12:08 ` Adrian Hunter
  2025-08-08 11:14 ` Amit Machhiwal
@ 2025-08-10 16:08 ` Aditya Bodkhe
  2 siblings, 0 replies; 4+ messages in thread
From: Aditya Bodkhe @ 2025-08-10 16:08 UTC (permalink / raw)
  To: Gautam Menghani, peterz, mingo, acme, namhyung, mark.rutland,
	alexander.shishkin, jolsa, irogers, adrian.hunter, kan.liang
  Cc: linux-perf-users, linux-kernel


On 04/08/25 4:36 pm, Gautam Menghani wrote:
> Since commit eead8a011477 ("libperf threadmap: Don't segv for index 0 for the
> NULL 'struct perf_thread_map' pointer"), perf_thread_map__pid() can
> check for a NULL map and return -1 if idx is 0. Cleanup
> auxtrace_mmap_params__set_idx() and remove the redundant NULL check.
>
> No functional change intended.
>
> Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
> ---
>   tools/perf/util/auxtrace.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index ebd32f1b8f12..5e437133c753 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -185,10 +185,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
>   
>   	if (per_cpu) {
>   		mp->cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
> -		if (evlist->core.threads)
> -			mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
> -		else
> -			mp->tid = -1;
> +		mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
>   	} else {
>   		mp->cpu.cpu = -1;
>   		mp->tid = perf_thread_map__pid(evlist->core.threads, idx);

LGTM.

Reviewed-by: Aditya Bodkhe <adityab1@linux.ibm.com>


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

end of thread, other threads:[~2025-08-10 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 11:06 [PATCH] perf auxtrace: Avoid redundant NULL check in auxtrace_mmap_params__set_idx() Gautam Menghani
2025-08-04 12:08 ` Adrian Hunter
2025-08-08 11:14 ` Amit Machhiwal
2025-08-10 16:08 ` Aditya Bodkhe

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