From patchwork Tue May 6 09:27:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 346090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1A57C1412DC for ; Tue, 6 May 2014 19:37:54 +1000 (EST) Received: from localhost ([::1]:33816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whbot-000140-SF for incoming@patchwork.ozlabs.org; Tue, 06 May 2014 05:37:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhboB-0008M5-VU for qemu-devel@nongnu.org; Tue, 06 May 2014 05:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Whbo4-0008Dm-DY for qemu-devel@nongnu.org; Tue, 06 May 2014 05:37:07 -0400 Received: from [59.151.112.132] (port=8790 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whbo4-0008DN-1t for qemu-devel@nongnu.org; Tue, 06 May 2014 05:37:00 -0400 X-IronPort-AV: E=Sophos;i="4.97,996,1389715200"; d="scan'208";a="30131281" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 06 May 2014 17:27:06 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s469TaGR003039; Tue, 6 May 2014 17:29:36 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Tue, 6 May 2014 17:29:45 +0800 From: Hu Tao To: Date: Tue, 6 May 2014 17:27:23 +0800 Message-ID: <6fe3433fa1b413777bb5ae1908c1155cc22306ae.1399365798.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Paolo Bonzini , Wanlong Gao , Igor Mammedov Subject: [Qemu-devel] [PATCH v3.1 02/31] 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 Signed-off-by: Hu Tao --- 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;