Skip to content

Commit

Permalink
perf bench numa: Fix immediate meeting of convergence condition
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
Petr Holasek authored and acmel committed Apr 27, 2015
1 parent 24f1ced commit 1d90a68
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/perf/bench/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ static int count_process_nodes(int process_nr)
td = g->threads + task_nr;

node = numa_node_of_cpu(td->curr_cpu);
if (node < 0) /* curr_cpu was likely still -1 */
return 0;

node_present[node] = 1;
}

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

if (!nodes) {
*strong = 0;
return;
}

nodes_min = min(nodes, nodes_min);
nodes_max = max(nodes, nodes_max);
}
Expand Down

0 comments on commit 1d90a68

Please sign in to comment.