On Mon, 9 Feb 2015 17:53:15 -0200 Eduardo Habkost <ehabk...@redhat.com> wrote:
> Each CPU can appear in only one NUMA node on the NUMA config. Reject > configuration if a CPU appears in multiple nodes. > > Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> > --- > numa.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/numa.c b/numa.c > index f768434..f004a74 100644 > --- a/numa.c > +++ b/numa.c > @@ -167,6 +167,31 @@ error: > return -1; > } > > +static void validate_numa_cpus(void) > +{ > + int i, cpu; > + DECLARE_BITMAP(present_cpus, MAX_CPUMASK_BITS); > + > + bitmap_zero(present_cpus, MAX_CPUMASK_BITS); > + for (i = 0; i < nb_numa_nodes; i++) { > + if (bitmap_intersects(present_cpus, numa_info[i].node_cpu, > + MAX_CPUMASK_BITS)) { > + bitmap_and(present_cpus, present_cpus, > + numa_info[i].node_cpu, MAX_CPUMASK_BITS); > + fprintf(stderr, "CPU(s) present in multiple NUMA nodes:"); > + for (cpu = find_first_bit(present_cpus, MAX_CPUMASK_BITS); > + cpu < MAX_CPUMASK_BITS; > + cpu = find_next_bit(present_cpus, MAX_CPUMASK_BITS, cpu + > 1)) { > + fprintf(stderr, " %d", cpu); > + } > + fprintf(stderr, "\n"); how about replacing a bunch if fprintf's with something like this: cpu = 0; while((cpu = find_next_bit(present_cpus, MAX_CPUMASK_BITS, cpu + 1)) !=MAX_CPUMASK_BITS) str = g_strdup_printf("%s %d", str, cpu); error_report("CPU(s) present in multiple NUMA nodes: %s\n", str); > + exit(1); > + } > + bitmap_or(present_cpus, present_cpus, > + numa_info[i].node_cpu, MAX_CPUMASK_BITS); > + } > +} > + > void parse_numa_opts(void) > { > int i; > @@ -244,6 +269,8 @@ void parse_numa_opts(void) > set_bit(i, numa_info[i % nb_numa_nodes].node_cpu); > } > } > + > + validate_numa_cpus(); > } > } >