Skip to contentSkip to conversation

perf c2c: Fix c2c report for empty numa node

PATCH In review Ravi Bangoria 2 participants 6 messages Feb 28, 2019 – Mar 2, 2019 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf c2c: Fix c2c report for empty numa node

perf c2c report fails if system has empty numa node(0 cpus):

  $ lscpu
  NUMA node0 CPU(s):   
  NUMA node1 CPU(s):   0-4
  $ sudo ./perf c2c report 
  node/cpu topology bugFailed setup nodes

Fix this.

---
 tools/perf/util/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cpumap.c +1 -1
index 383674f448fc..517c3f37c613 100644
@@ -261,7 +261,7 @@ struct cpu_map *cpu_map__dummy_new(void)
 	struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
 
 	if (cpus != NULL) {
-		cpus->nr = 1;
+		cpus->nr = 0;
 		cpus->map[0] = -1;
 		refcount_set(&cpus->refcnt, 1);
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 22 lines · Ravi Bangoria

perf c2c report fails if system has empty numa node(0 cpus):

  $ lscpu
  NUMA node0 CPU(s):   
  NUMA node1 CPU(s):   0-4
  $ sudo ./perf c2c report 
  node/cpu topology bugFailed setup nodes

Fix this.

---
 tools/perf/util/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cpumap.c +0 -0
index 383674f448fc..517c3f37c613 100644

tools/perf/util/cpumap.c struct cpu_map *cpu_map__dummy_new(void) · line 264

Quoted 5 lines
tools/perf/util/cpumap.c +1 -1
@@ -261,7 +261,7 @@ struct cpu_map *cpu_map__dummy_new(void)
 	struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
 
 	if (cpus != NULL) {
-		cpus->nr = 1;
+		cpus->nr = 0;

you can't do this, there's one item in the map, nr needs to reflect that.. it breaks 'perf test' badly

so the node is empty.. we need to teach c2c to work with that I'll check

jirka

Quoted 6 lines
tools/perf/util/cpumap.c +0 -0
 		cpus->map[0] = -1;
 		refcount_set(&cpus->refcnt, 1);
 	}
Signature · 1 line
2.17.1
#2 lore raw
Quoted 32 lines · Jiri Olsa
Quoted 22 lines · Ravi Bangoria

perf c2c report fails if system has empty numa node(0 cpus):

  $ lscpu
  NUMA node0 CPU(s):   
  NUMA node1 CPU(s):   0-4
  $ sudo ./perf c2c report 
  node/cpu topology bugFailed setup nodes

Fix this.

---
 tools/perf/util/cpumap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/cpumap.c +0 -0
index 383674f448fc..517c3f37c613 100644

tools/perf/util/cpumap.c struct cpu_map *cpu_map__dummy_new(void) · line 264

Quoted 5 lines
tools/perf/util/cpumap.c +1 -1
@@ -261,7 +261,7 @@ struct cpu_map *cpu_map__dummy_new(void)
 	struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
 
 	if (cpus != NULL) {
-		cpus->nr = 1;
+		cpus->nr = 0;

you can't do this, there's one item in the map, nr needs to reflect that.. it breaks 'perf test' badly

Quoted 2 lines

so the node is empty.. we need to teach c2c to work with that I'll check

how about attached change (untested)?

but I wonder there are some other hidden
bugs wrt empty node

jirka

---

tools/perf/builtin-c2c.c +6 -2
index 4272763a5e96..9e6cc868bdb4 100644
@@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session)
 		if (!set)
 			return -ENOMEM;
 
+		nodes[node] = set;
+
+		/* empty node, skip */
+		if (cpu_map__empty(map))
+			continue;
+
 		for (cpu = 0; cpu < map->nr; cpu++) {
 			set_bit(map->map[cpu], set);
 
@@ -2064,8 +2070,6 @@ static int setup_nodes(struct perf_session *session)
 
 			cpu2node[map->map[cpu]] = node;
 		}
-
-		nodes[node] = set;
 	}
 
 	setup_nodes_header();
#3 lore raw
Quoted 1 line · Jiri Olsa

how about attached change (untested)?

LGTM. Would you mind sending a patch.

Quoted 35 lines

but I wonder there are some other hidden
bugs wrt empty node

jirka

---

tools/perf/builtin-c2c.c +6 -2
index 4272763a5e96..9e6cc868bdb4 100644
@@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session)
 		if (!set)
 			return -ENOMEM;
 
+		nodes[node] = set;
+
+		/* empty node, skip */
+		if (cpu_map__empty(map))
+			continue;
+
 		for (cpu = 0; cpu < map->nr; cpu++) {
 			set_bit(map->map[cpu], set);
 
@@ -2064,8 +2070,6 @@ static int setup_nodes(struct perf_session *session)
 
 			cpu2node[map->map[cpu]] = node;
 		}
-
-		nodes[node] = set;
 	}
 
 	setup_nodes_header();
#4 lore raw
Quoted 5 lines · Ravi Bangoria
Quoted 1 line · Jiri Olsa

how about attached change (untested)?

LGTM. Would you mind sending a patch.

attached, please test on your system

thanks,
jirka

---
Ravi Bangoria reported that we fail with empty
numa node with following message:

  $ lscpu
  NUMA node0 CPU(s):
  NUMA node1 CPU(s):   0-4
  $ sudo ./perf c2c report
  node/cpu topology bugFailed setup nodes

Fixing this by detecting empty node and keeping
its cpu set empty.

---
 tools/perf/builtin-c2c.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/perf/builtin-c2c.c +6 -2
index 4272763a5e96..9e6cc868bdb4 100644
@@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session)
 		if (!set)
 			return -ENOMEM;
 
+		nodes[node] = set;
+
+		/* empty node, skip */
+		if (cpu_map__empty(map))
+			continue;
+
 		for (cpu = 0; cpu < map->nr; cpu++) {
 			set_bit(map->map[cpu], set);
 
@@ -2064,8 +2070,6 @@ static int setup_nodes(struct perf_session *session)
 
 			cpu2node[map->map[cpu]] = node;
 		}
-
-		nodes[node] = set;
 	}
 
 	setup_nodes_header();
Signature · 1 line
2.17.2
author Tested-by
#5 lore raw
Quoted 10 lines · Jiri Olsa

Ravi Bangoria reported that we fail with empty
numa node with following message:

  $ lscpu
  NUMA node0 CPU(s):
  NUMA node1 CPU(s):   0-4
  $ sudo ./perf c2c report
  node/cpu topology bugFailed setup nodes
Quoted 6 lines

Fixing this by detecting empty node and keeping
its cpu set empty.