[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/5] tcg: Refactor helper_lookup_tb_ptr
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/5] tcg: Refactor helper_lookup_tb_ptr |
Date: |
Fri, 16 Jun 2017 16:19:21 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Wed, Jun 14, 2017 at 12:48:17 -0700, Richard Henderson wrote:
> --- a/tcg-runtime.c
> +++ b/tcg-runtime.c
(snip)
> tb = tb_htable_lookup(cpu, addr, cs_base, flags);
> - if (likely(tb)) {
> - atomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(addr)], tb);
> - goto found;
> + if (!tb) {
> + return ret;
While booting debian-arm I'm measuring (see below) a hit rate in the
high 90's for the htable lookups here, so adding an 'unlikely()'
hint would be a good idea.
[ I'm using the patch currently in your tcg-next branch, i.e. 0a2adf4e2 ]
E.
The below prints during bootup+shutdown:
hit rate: 94.599500%
hit rate: 95.794100%
hit rate: 96.617900%
hit rate: 96.527275%
hit rate: 96.341320%
hit rate: 96.641883%
diff --git a/tcg-runtime.c b/tcg-runtime.c
index ec3a34e..addc3fa 100644
--- a/tcg-runtime.c
+++ b/tcg-runtime.c
@@ -150,6 +150,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_ulong
addr)
TranslationBlock *tb;
target_ulong cs_base, pc;
uint32_t flags, addr_hash;
+ static unsigned long long accesses, found;
addr_hash = tb_jmp_cache_hash_func(addr);
tb = atomic_rcu_read(&cpu->tb_jmp_cache[addr_hash]);
@@ -159,11 +160,16 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env,
target_ulong addr)
&& tb->pc == addr
&& tb->cs_base == cs_base
&& tb->flags == flags))) {
+ accesses++;
+ if (!(accesses % 1000000)) {
+ fprintf(stderr, "hit rate: %f%%\n", (double)found * 100 /
accesses);
+ }
tb = tb_htable_lookup(cpu, addr, cs_base, flags);
if (!tb) {
return tcg_ctx.code_gen_epilogue;
}
atomic_set(&cpu->tb_jmp_cache[addr_hash], tb);
+ found++;
}
qemu_log_mask_and_addr(CPU_LOG_EXEC, addr,
[Qemu-devel] [PATCH v2 4/5] target/s390x: Exit after changing PSW mask, Richard Henderson, 2017/06/14