From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvHH-0000wy-UJ for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLvHD-0005rv-0u for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:02:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvHC-0005rq-Kt for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:01:58 -0500 Date: Thu, 12 Feb 2015 16:01:49 +0100 From: Igor Mammedov Message-ID: <20150212160149.3adcf821@nial.brq.redhat.com> In-Reply-To: <1423511596-2584-3-git-send-email-ehabkost@redhat.com> References: <1423511596-2584-1-git-send-email-ehabkost@redhat.com> <1423511596-2584-3-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] numa: Reject configuration if CPU appears on multiple nodes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Paolo Bonzini , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Hu Tao On Mon, 9 Feb 2015 17:53:15 -0200 Eduardo Habkost 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 > --- > 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); naming is a bit confusing, it's not really present CPUs but more like possible_cpus > + > + 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"); > + 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(); > } > } >