From: Anthony Liguori <anthony@codemonkey.ws>
To: Avi Kivity <avi@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu_vmalloc: align properly for transparent hugepages and KVM
Date: Fri, 09 Sep 2011 13:34:18 -0500 [thread overview]
Message-ID: <4E6A5C2A.8060601@codemonkey.ws> (raw)
In-Reply-To: <1315210025-17727-1-git-send-email-avi@redhat.com>
On 09/05/2011 03:07 AM, Avi Kivity wrote:
> To make good use of transparent hugepages, KVM requires that guest-physical
> and host-virtual addresses share the low 21 bits (as opposed to just the low
> 12 bits normally required).
>
> Adjust qemu_vmalloc() to honor that requirement. Ignore it for small regions
> to avoid fragmentation.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> oslib-posix.c | 14 +++++++++++++-
> 1 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/oslib-posix.c b/oslib-posix.c
> index 196099c..a304fb0 100644
> --- a/oslib-posix.c
> +++ b/oslib-posix.c
> @@ -35,6 +35,13 @@
> extern int daemon(int, int);
> #endif
>
> +#if defined(__linux__)&& defined(__x86_64__)
> + /* Use 2MB alignment so transparent hugepages can be used by KVM */
> +# define QEMU_VMALLOC_ALIGN (512 * 4096)
> +#else
> +# define QEMU_VMALLOC_ALIGN getpagesize()
> +#endif
> +
> #include "config-host.h"
> #include "sysemu.h"
> #include "trace.h"
> @@ -80,7 +87,12 @@ int qemu_daemon(int nochdir, int noclose)
> void *qemu_vmalloc(size_t size)
> {
> void *ptr;
> - ptr = qemu_memalign(getpagesize(), size);
> + size_t align = QEMU_VMALLOC_ALIGN;
> +
> + if (size< align) {
> + align = getpagesize();
> + }
> + ptr = qemu_memalign(align, size);
> trace_qemu_vmalloc(size, ptr);
> return ptr;
> }
prev parent reply other threads:[~2011-09-09 18:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 8:07 [Qemu-devel] [PATCH] qemu_vmalloc: align properly for transparent hugepages and KVM Avi Kivity
2011-09-05 10:10 ` Jan Kiszka
2011-09-05 10:21 ` Avi Kivity
2011-09-09 18:34 ` Anthony Liguori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E6A5C2A.8060601@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.