From nobody Wed Oct 29 17:31:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524823584951607.5560389296976; Fri, 27 Apr 2018 03:06:24 -0700 (PDT) Received: from localhost ([::1]:46947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC0Gl-000170-LK for importer@patchew.org; Fri, 27 Apr 2018 06:06:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBzb9-0002o4-DP for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBzb8-0002YF-ED for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:23:23 -0400 Received: from ozlabs.org ([203.11.71.1]:60429) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBzb8-0002XJ-0s; Fri, 27 Apr 2018 05:23:22 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 40XT2w4T9hz9sY0; Fri, 27 Apr 2018 19:21:43 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1524820904; bh=pRXAMCMTpdcZiBX4eGIikSCVoYoLY4CdC5TpildW1Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaQP0A8cRIzt95VEwOofx4r1xLUrt15QWQDgtILFanzC3mCs9dCwV8qU5x8Hj5Z7T Ax3jGPpOdq0eh/jzg5dR64NYCv17hsCyR50iTZ4ty8iMQOtZnc71ATdnmw69DlHjv7 TN9igJmXdwNULhc93qbLbq13zAxcImV12wiUWH3g= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 27 Apr 2018 19:21:26 +1000 Message-Id: <20180427092126.24812-50-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427092126.24812-1-david@gibson.dropbear.id.au> References: <20180427092126.24812-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 49/49] Clear mem_path if we fall back to anonymous RAM allocation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, groug@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the -mem-path option is set, we attempt to map the guest's RAM from a file in the given path; it's usually used to back guest RAM with hugepages. If we're unable to (e.g. not enough free hugepages) then we fall back to allocating normal anonymous pages. This behaviour can be surprising, but a comment in allocate_system_memory_nonnuma() suggests it's legacy behaviour we can't change. What really isn't ok, though, is that in this case we leave mem_path set. That means functions which attempt to determine the pagesize of main RAM can erroneously think it is hugepage based on the requested path, even though it's not. This is particular bad for the pseries machine type. KVM HV limitations mean the guest can't use pagesizes larger than the host page size used to back RAM. That means that such a fallback, rather than merely giving poorer performance than expected will cause the guest to freeze up early in boot as it attempts to use large page mappings that can't work. This patch addresses the problem by clearing the mem_path variable when we fall back to anonymous pages, meaning that subsequent attempts to determine the RAM page size will get an accurate result. Signed-off-by: David Gibson --- numa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/numa.c b/numa.c index 1116c90af9..78a869e598 100644 --- a/numa.c +++ b/numa.c @@ -469,6 +469,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion= *mr, Object *owner, /* Legacy behavior: if allocation failed, fall back to * regular RAM allocation. */ + mem_path =3D NULL; memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &e= rror_fatal); } #else --=20 2.14.3