summaryrefslogtreecommitdiff
path: root/tools/perf/bench/numa.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/bench/numa.c')
-rw-r--r--tools/perf/bench/numa.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 31e2601d39c8..9066511aed47 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -248,16 +248,21 @@ static int is_node_present(int node)
static bool node_has_cpus(int node)
{
struct bitmask *cpu = numa_allocate_cpumask();
+ bool ret = false; /* fall back to nocpus */
unsigned int i;
- if (cpu && !numa_node_to_cpus(node, cpu)) {
+ BUG_ON(!cpu);
+ if (!numa_node_to_cpus(node, cpu)) {
for (i = 0; i < cpu->size; i++) {
- if (numa_bitmask_isbitset(cpu, i))
- return true;
+ if (numa_bitmask_isbitset(cpu, i)) {
+ ret = true;
+ break;
+ }
}
}
+ numa_free_cpumask(cpu);
- return false; /* lets fall back to nocpus safely */
+ return ret;
}
static cpu_set_t bind_to_cpu(int target_cpu)