From patchwork Mon Feb 9 19:53:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 438068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D6FF7140161 for ; Tue, 10 Feb 2015 06:55:22 +1100 (AEDT) Received: from localhost ([::1]:34926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKuQT-0007Bo-6O for incoming@patchwork.ozlabs.org; Mon, 09 Feb 2015 14:55:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKuOm-0004EG-0X for qemu-devel@nongnu.org; Mon, 09 Feb 2015 14:53:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKuOf-0006Sg-Qe for qemu-devel@nongnu.org; Mon, 09 Feb 2015 14:53:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKuOf-0006SZ-Hn for qemu-devel@nongnu.org; Mon, 09 Feb 2015 14:53:29 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t19JrR1U022866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Feb 2015 14:53:27 -0500 Received: from localhost (ovpn-113-167.phx2.redhat.com [10.3.113.167]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t19JrQAk007929; Mon, 9 Feb 2015 14:53:26 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 9 Feb 2015 17:53:15 -0200 Message-Id: <1423511596-2584-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1423511596-2584-1-git-send-email-ehabkost@redhat.com> References: <1423511596-2584-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Igor Mammedov , Hu Tao , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v2 2/3] numa: Reject configuration if CPU appears on multiple nodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); + + 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(); } }