Skip to content

Commit 1d90a68

Browse files
Petr Holasekacmel
authored andcommitted
perf bench numa: Fix immediate meeting of convergence condition
This patch fixes the race in the beginning of benchmark run when some threads hasn't got assigned curr_cpu yet so they don't occur in nodes-of-process stats and benchmark concludes that all remaining threads are converged already. The race can be reproduced with small amount of threads and some bigger amount of shared process memory, e.g. one process, two threads and 5GB of process memory. Signed-off-by: Petr Holasek <pholasek@redhat.com> Reviewed-by: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1429198699-25039-4-git-send-email-pholasek@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 24f1ced commit 1d90a68

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/perf/bench/numa.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,9 @@ static int count_process_nodes(int process_nr)
828828
td = g->threads + task_nr;
829829

830830
node = numa_node_of_cpu(td->curr_cpu);
831+
if (node < 0) /* curr_cpu was likely still -1 */
832+
return 0;
833+
831834
node_present[node] = 1;
832835
}
833836

@@ -882,6 +885,11 @@ static void calc_convergence_compression(int *strong)
882885
for (p = 0; p < g->p.nr_proc; p++) {
883886
unsigned int nodes = count_process_nodes(p);
884887

888+
if (!nodes) {
889+
*strong = 0;
890+
return;
891+
}
892+
885893
nodes_min = min(nodes, nodes_min);
886894
nodes_max = max(nodes, nodes_max);
887895
}

0 commit comments

Comments
 (0)