From nobody Sat May 4 00:10:45 2024 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 1524122559759799.1729844039289; Thu, 19 Apr 2018 00:22:39 -0700 (PDT) Received: from localhost ([::1]:55711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f93tv-0001gU-0V for importer@patchew.org; Thu, 19 Apr 2018 03:22:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f93sp-00014l-4L for qemu-devel@nongnu.org; Thu, 19 Apr 2018 03:21:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f93so-00027M-3v for qemu-devel@nongnu.org; Thu, 19 Apr 2018 03:21:31 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:39807) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f93sn-00025a-LN; Thu, 19 Apr 2018 03:21:30 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 40RVlq14PQz9s27; Thu, 19 Apr 2018 17:21:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1524122487; bh=7EnMstYXjmQzH3vdScl91L8YFIML9z+XIRPV3u2Fu8M=; h=From:To:Cc:Subject:Date:From; b=LxLbY9vEhOi2RBs0VcRELsyN2YvLS9mxRvHwAbVx+aGIV6BAUmoHqhSqPaBanqJ2K MPRiQpqzRPGk/yZG7GFKqWtju4+KDg8a94OkxmjgdNz9tEPHZBywbO2aeozD4oX5Kr TJlM7SJvSTl8uYMoaLehrZDtHI12VaKQ6ZKqZZWY= From: David Gibson To: pbonzini@redhat.com, imammedo@redhat.com, ehabkost@redhat.com Date: Thu, 19 Apr 2018 17:21:23 +1000 Message-Id: <20180419072123.682-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH for-2.13] 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: qemu-devel@nongnu.org, David Gibson , qemu-ppc@nongnu.org, groug@kaod.org, clg@kaod.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 that 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(+) Paolo et al, as with my earlier patches adding some extensions to the helpers for determining backing page sizes, if there are no objections can I get an ack to merge this via my ppc tree? 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