Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Petr Holasek and committed by
Arnaldo Carvalho de Melo
1d90a685 24f1ced1

+8
+8
tools/perf/bench/numa.c
··· 828 828 td = g->threads + task_nr; 829 829 830 830 node = numa_node_of_cpu(td->curr_cpu); 831 + if (node < 0) /* curr_cpu was likely still -1 */ 832 + return 0; 833 + 831 834 node_present[node] = 1; 832 835 } 833 836 ··· 884 881 885 882 for (p = 0; p < g->p.nr_proc; p++) { 886 883 unsigned int nodes = count_process_nodes(p); 884 + 885 + if (!nodes) { 886 + *strong = 0; 887 + return; 888 + } 887 889 888 890 nodes_min = min(nodes, nodes_min); 889 891 nodes_max = max(nodes, nodes_max);