linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: handle TOPOLOGY headers with no CPU
@ 2019-01-19  8:12 Stephane Eranian
  2019-01-20 18:19 ` Jiri Olsa
  2019-01-22 11:36 ` [tip:perf/urgent] perf tools: Handle " tip-bot for Stephane Eranian
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2019-01-19  8:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: acme, jolsa, peterz, mingo, ak, kan.liang

This patch fixes an issue in cpumap.c when used with the
TOPOLOGY header. In some configurations, some NUMA nodes may
have no CPU (empty cpulist). Yet a cpumap map must be created
otherwise perf abort with an error. This patch handles this
case by creating a dummy map.

Before:
$ perf record -o - -e cycles noploop 2 | perf script -i -
0x6e8 [0x6c]: failed to process type: 80

After:
$ perf record -o - -e cycles noploop 2 | perf script -i -
noploop for 2 seconds

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/util/cpumap.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 1ccbd3342069..383674f448fc 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
 	if (!cpu_list)
 		return cpu_map__read_all_cpu_map();
 
-	if (!isdigit(*cpu_list))
+	/*
+	 * must handle the case of empty cpumap to cover
+	 * TOPOLOGY header for NUMA nodes with no CPU
+	 * ( e.g., because of CPU hotplug)
+	 */
+	if (!isdigit(*cpu_list) && *cpu_list != '\0')
 		goto out;
 
 	while (isdigit(*cpu_list)) {
@@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
 
 	if (nr_cpus > 0)
 		cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
-	else
+	else if (*cpu_list != '\0')
 		cpus = cpu_map__default_new();
+	else
+		cpus = cpu_map__dummy_new();
 invalid:
 	free(tmp_cpus);
 out:
-- 
2.7.4


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

* Re: [PATCH] perf tools: handle TOPOLOGY headers with no CPU
  2019-01-19  8:12 [PATCH] perf tools: handle TOPOLOGY headers with no CPU Stephane Eranian
@ 2019-01-20 18:19 ` Jiri Olsa
  2019-01-22 11:36 ` [tip:perf/urgent] perf tools: Handle " tip-bot for Stephane Eranian
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2019-01-20 18:19 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, acme, peterz, mingo, ak, kan.liang

On Sat, Jan 19, 2019 at 12:12:39AM -0800, Stephane Eranian wrote:
> This patch fixes an issue in cpumap.c when used with the
> TOPOLOGY header. In some configurations, some NUMA nodes may
> have no CPU (empty cpulist). Yet a cpumap map must be created
> otherwise perf abort with an error. This patch handles this
> case by creating a dummy map.
> 
> Before:
> $ perf record -o - -e cycles noploop 2 | perf script -i -
> 0x6e8 [0x6c]: failed to process type: 80
> 
> After:
> $ perf record -o - -e cycles noploop 2 | perf script -i -
> noploop for 2 seconds
> 
> Signed-off-by: Stephane Eranian <eranian@google.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/util/cpumap.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
> index 1ccbd3342069..383674f448fc 100644
> --- a/tools/perf/util/cpumap.c
> +++ b/tools/perf/util/cpumap.c
> @@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
>  	if (!cpu_list)
>  		return cpu_map__read_all_cpu_map();
>  
> -	if (!isdigit(*cpu_list))
> +	/*
> +	 * must handle the case of empty cpumap to cover
> +	 * TOPOLOGY header for NUMA nodes with no CPU
> +	 * ( e.g., because of CPU hotplug)
> +	 */
> +	if (!isdigit(*cpu_list) && *cpu_list != '\0')
>  		goto out;
>  
>  	while (isdigit(*cpu_list)) {
> @@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
>  
>  	if (nr_cpus > 0)
>  		cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
> -	else
> +	else if (*cpu_list != '\0')
>  		cpus = cpu_map__default_new();
> +	else
> +		cpus = cpu_map__dummy_new();
>  invalid:
>  	free(tmp_cpus);
>  out:
> -- 
> 2.7.4
> 

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

* [tip:perf/urgent] perf tools: Handle TOPOLOGY headers with no CPU
  2019-01-19  8:12 [PATCH] perf tools: handle TOPOLOGY headers with no CPU Stephane Eranian
  2019-01-20 18:19 ` Jiri Olsa
@ 2019-01-22 11:36 ` tip-bot for Stephane Eranian
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Stephane Eranian @ 2019-01-22 11:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, linux-kernel, kan.liang, ak, hpa, acme, eranian, tglx,
	peterz, mingo

Commit-ID:  1497e804d1a6e2bd9107ddf64b0310449f4673eb
Gitweb:     https://git.kernel.org/tip/1497e804d1a6e2bd9107ddf64b0310449f4673eb
Author:     Stephane Eranian <eranian@google.com>
AuthorDate: Sat, 19 Jan 2019 00:12:39 -0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 21 Jan 2019 11:28:56 -0300

perf tools: Handle TOPOLOGY headers with no CPU

This patch fixes an issue in cpumap.c when used with the TOPOLOGY
header. In some configurations, some NUMA nodes may have no CPU (empty
cpulist). Yet a cpumap map must be created otherwise perf abort with an
error. This patch handles this case by creating a dummy map.

  Before:

  $ perf record -o - -e cycles noploop 2 | perf script -i -
  0x6e8 [0x6c]: failed to process type: 80

  After:

  $ perf record -o - -e cycles noploop 2 | perf script -i -
  noploop for 2 seconds

Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1547885559-1657-1-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/cpumap.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 1ccbd3342069..383674f448fc 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
 	if (!cpu_list)
 		return cpu_map__read_all_cpu_map();
 
-	if (!isdigit(*cpu_list))
+	/*
+	 * must handle the case of empty cpumap to cover
+	 * TOPOLOGY header for NUMA nodes with no CPU
+	 * ( e.g., because of CPU hotplug)
+	 */
+	if (!isdigit(*cpu_list) && *cpu_list != '\0')
 		goto out;
 
 	while (isdigit(*cpu_list)) {
@@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
 
 	if (nr_cpus > 0)
 		cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
-	else
+	else if (*cpu_list != '\0')
 		cpus = cpu_map__default_new();
+	else
+		cpus = cpu_map__dummy_new();
 invalid:
 	free(tmp_cpus);
 out:

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

end of thread, other threads:[~2019-01-22 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-19  8:12 [PATCH] perf tools: handle TOPOLOGY headers with no CPU Stephane Eranian
2019-01-20 18:19 ` Jiri Olsa
2019-01-22 11:36 ` [tip:perf/urgent] perf tools: Handle " tip-bot for Stephane Eranian

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