From patchwork Fri Oct 5 19:47:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 189589 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ADFD42C0336 for ; Sat, 6 Oct 2012 06:04:00 +1000 (EST) Received: from localhost ([::1]:43334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKE7p-0002AM-B1 for incoming@patchwork.ozlabs.org; Fri, 05 Oct 2012 16:03:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKE7i-0002A3-Qs for qemu-devel@nongnu.org; Fri, 05 Oct 2012 16:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TKE7i-0006iL-0q for qemu-devel@nongnu.org; Fri, 05 Oct 2012 16:03:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKE7h-0006i8-PJ for qemu-devel@nongnu.org; Fri, 05 Oct 2012 16:03:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q95K3lnd027340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Oct 2012 16:03:48 -0400 Received: from doriath.home (ovpn-116-84.ams2.redhat.com [10.36.116.84]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q95K3iM5018206; Fri, 5 Oct 2012 16:03:45 -0400 Date: Fri, 5 Oct 2012 16:47:57 -0300 From: Luiz Capitulino To: qemu-devel Message-ID: <20121005164758.4808b2d1@doriath.home> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, jan.kiszka@siemens.com Subject: [Qemu-devel] [PATCH] Call MADV_HUGEPAGE for guest RAM allocations 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 This makes it possible for QEMU to use transparent huge pages (THP) when transparent_hugepage/enabled=madvise. Otherwise THP is only used when it's enabled system wide. Signed-off-by: Luiz Capitulino --- exec.c | 1 + osdep.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/exec.c b/exec.c index 1114a09..7504909 100644 --- a/exec.c +++ b/exec.c @@ -2584,6 +2584,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff); qemu_ram_setup_dump(new_block->host, size); + qemu_madvise(new_block->host, size, QEMU_MADV_HUGEPAGE); if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); diff --git a/osdep.h b/osdep.h index cb213e0..c5fd3d9 100644 --- a/osdep.h +++ b/osdep.h @@ -108,6 +108,11 @@ void qemu_vfree(void *ptr); #else #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID #endif +#ifdef MADV_HUGEPAGE +#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE +#else +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#endif #elif defined(CONFIG_POSIX_MADVISE)