Patchwork exec: Advise huge pages for the TCG code gen buffer

login
register
mail settings
Submitter Richard Henderson
Date Nov. 1, 2012, 10:20 p.m.
Message ID <1351808446-2436-1-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/196393/
State New
Headers show

Comments

Richard Henderson - Nov. 1, 2012, 10:20 p.m.
After allocating 32MB or more contiguous memory, huge pages
would seem to be ideal.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 exec.c | 2 ++
 1 file changed, 2 insertions(+)
Blue Swirl - Dec. 8, 2012, 5:52 p.m.
Thanks, applied.

On Thu, Nov 1, 2012 at 10:20 PM, Richard Henderson <rth@twiddle.net> wrote:
> After allocating 32MB or more contiguous memory, huge pages
> would seem to be ideal.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  exec.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/exec.c b/exec.c
> index df67938..ab07f68 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -602,6 +602,8 @@ static inline void code_gen_alloc(size_t tb_size)
>          exit(1);
>      }
>
> +    qemu_madvise(code_gen_buffer, code_gen_buffer_size, QEMU_MADV_HUGEPAGE);
> +
>      /* Steal room for the prologue at the end of the buffer.  This ensures
>         (via the MAX_CODE_GEN_BUFFER_SIZE limits above) that direct branches
>         from TB's to the prologue are going to be in range.  It also means
> --
> 1.7.11.7
>

Patch

diff --git a/exec.c b/exec.c
index df67938..ab07f68 100644
--- a/exec.c
+++ b/exec.c
@@ -602,6 +602,8 @@  static inline void code_gen_alloc(size_t tb_size)
         exit(1);
     }
 
+    qemu_madvise(code_gen_buffer, code_gen_buffer_size, QEMU_MADV_HUGEPAGE);
+
     /* Steal room for the prologue at the end of the buffer.  This ensures
        (via the MAX_CODE_GEN_BUFFER_SIZE limits above) that direct branches
        from TB's to the prologue are going to be in range.  It also means