From patchwork Wed Mar 26 10:36:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 333816 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 DC538140086 for ; Wed, 26 Mar 2014 22:10:55 +1100 (EST) Received: from localhost ([::1]:46884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSljR-0001bE-Du for incoming@patchwork.ozlabs.org; Wed, 26 Mar 2014 07:10:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSlhl-0000vo-9c for qemu-devel@nongnu.org; Wed, 26 Mar 2014 07:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSlhg-0002TP-LN for qemu-devel@nongnu.org; Wed, 26 Mar 2014 07:09:09 -0400 Received: from [59.151.112.132] (port=20400 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSlhg-0002Rj-6m for qemu-devel@nongnu.org; Wed, 26 Mar 2014 07:09:04 -0400 X-IronPort-AV: E=Sophos;i="4.97,734,1389715200"; d="scan'208";a="28487311" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Mar 2014 18:34:30 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s2QAap5G003094; Wed, 26 Mar 2014 18:36:51 +0800 Received: from G08CNEXMBPEKD03.g08.fujitsu.local ([10.167.33.86]) by G08CNEXCHPEKD02.g08.fujitsu.local ([10.167.33.83]) with mapi id 14.03.0146.002; Wed, 26 Mar 2014 18:36:55 +0800 From: "hutao@cn.fujitsu.com" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 02/34] NUMA: check if the total numa memory size is equal to ram_size Thread-Index: AQHPSN9S00BvuR73QkyjE/Z8RIhIgA== Date: Wed, 26 Mar 2014 10:36:57 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.167.226.102] MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: "ehabkost@redhat.com" , "imammedo@redhat.com" , "mtosatti@redhat.com" , Paolo Bonzini , "a.motakis@virtualopensystems.com" , "gaowanlong@cn.fujitsu.com" Subject: [Qemu-devel] [PATCH v3 02/34] NUMA: check if the total numa memory size is equal to ram_size 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 From: Wanlong Gao If the total number of the assigned numa nodes memory is not equal to the assigned ram size, it will write the wrong data to ACPI table, then the guest will ignore the wrong ACPI table and recognize all memory to one node. It's buggy, we should check it to ensure that we write the right data to ACPI table. Signed-off-by: Wanlong Gao Reviewed-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- numa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/numa.c b/numa.c index 395c14f..1d2f761 100644 --- a/numa.c +++ b/numa.c @@ -27,6 +27,8 @@ #include "exec/cpu-common.h" #include "qemu/bitmap.h" #include "qom/cpu.h" +#include "qemu/error-report.h" +#include "include/exec/cpu-common.h" /* for RAM_ADDR_FMT */ static void numa_node_parse_cpus(int nodenr, const char *cpus) { @@ -127,6 +129,7 @@ void numa_add(const char *optarg) void set_numa_nodes(void) { if (nb_numa_nodes > 0) { + uint64_t numa_total; int i; if (nb_numa_nodes > MAX_NODES) { @@ -154,6 +157,17 @@ void set_numa_nodes(void) node_mem[i] = ram_size - usedmem; } + numa_total = 0; + for (i = 0; i < nb_numa_nodes; i++) { + numa_total += node_mem[i]; + } + if (numa_total != ram_size) { + error_report("qemu: total memory size for NUMA nodes (%" PRIu64 ")" + " should equal to ram_size (" RAM_ADDR_FMT ")\n", + numa_total, ram_size); + exit(1); + } + for (i = 0; i < nb_numa_nodes; i++) { if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) { break;