From patchwork Fri May 9 06:24:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 347299 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 921A2140109 for ; Fri, 9 May 2014 16:26:34 +1000 (EST) Received: from localhost ([::1]:50878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WieGO-0006FH-DR for incoming@patchwork.ozlabs.org; Fri, 09 May 2014 02:26:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WieG0-0005lo-GU for qemu-devel@nongnu.org; Fri, 09 May 2014 02:26:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WieFq-0003Vs-RI for qemu-devel@nongnu.org; Fri, 09 May 2014 02:26:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WieFq-0003Vf-JX for qemu-devel@nongnu.org; Fri, 09 May 2014 02:25:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s496PrYZ026904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 May 2014 02:25:54 -0400 Received: from amt.cnet (vpn1-5-62.gru2.redhat.com [10.97.5.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s496PqSm005368; Fri, 9 May 2014 02:25:53 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 45538100359; Fri, 9 May 2014 03:24:55 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id s496Osot029414; Fri, 9 May 2014 03:24:54 -0300 Date: Fri, 9 May 2014 03:24:52 -0300 From: Marcelo Tosatti To: Hu Tao Message-ID: <20140509062452.GA29352@amt.cnet> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , qemu-devel@nongnu.org, Igor Mammedov Subject: [Qemu-devel] [PATCH] preallocate memory after NUMA policy configuration 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 (note: applies on top of patchset of current thread) Preallocate memory after the NUMA policy has been instantiated. This is necessary to guarantee memory is allocated with specified NUMA policy in place. Signed-off-by: Marcelo Tosatti diff --git a/backends/hostmem.c b/backends/hostmem.c index d3f8476..3cfa8a0 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -293,9 +293,6 @@ host_memory_backend_memory_init(UserCreatable *uc, Error **errp) if (!backend->dump) { qemu_madvise(ptr, sz, QEMU_MADV_DONTDUMP); } - if (backend->prealloc) { - os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz); - } #ifdef CONFIG_NUMA unsigned long maxnode = find_last_bit(backend->host_nodes, MAX_NODES); @@ -310,6 +307,9 @@ host_memory_backend_memory_init(UserCreatable *uc, Error **errp) return; } #endif + if (backend->prealloc) { + os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz); + } } MemoryRegion *