qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
To: Richard Henderson <rth@twiddle.net>,
	qemu-devel@nongnu.org, "Emilio G. Cota" <cota@braap.org>
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PULL 15/15] translate-all: add tb hash bucket info to 'info jit' dump
Date: Fri, 22 Jul 2016 17:04:17 +0800	[thread overview]
Message-ID: <5791E191.4010404@cn.fujitsu.com> (raw)
In-Reply-To: <1465568813-19771-16-git-send-email-rth@twiddle.net>

On 06/10/2016 10:26 PM, Richard Henderson wrote:
> From: "Emilio G. Cota" <cota@braap.org>
>
> Examples:
>
> - Good hashing, i.e. tb_hash_func5(phys_pc, pc, flags):
> TB count            715135/2684354
> [...]
> TB hash buckets     388775/524288 (74.15% head buckets used)
> TB hash occupancy   33.04% avg chain occ. Histogram: [0,10)%|▆ █  ▅▁▃▁▁|[90,100]%
> TB hash avg chain   1.017 buckets. Histogram: 1|█▁▁|3
>
> - Not-so-good hashing, i.e. tb_hash_func5(phys_pc, pc, 0):
> TB count            712636/2684354
> [...]
> TB hash buckets     344924/524288 (65.79% head buckets used)
> TB hash occupancy   31.64% avg chain occ. Histogram: [0,10)%|█ ▆  ▅▁▃▁▂|[90,100]%
> TB hash avg chain   1.047 buckets. Histogram: 1|█▁▁▁|4
>
> - Bad hashing, i.e. tb_hash_func5(phys_pc, 0, 0):
> TB count            702818/2684354
> [...]
> TB hash buckets     112741/524288 (21.50% head buckets used)
> TB hash occupancy   10.15% avg chain occ. Histogram: [0,10)%|█ ▁  ▁▁▁▁▁|[90,100]%
> TB hash avg chain   2.107 buckets. Histogram: [1.0,10.2)|█▁▁▁▁▁▁▁▁▁|[83.8,93.0]
>
> - Good hashing, but no auto-resize:
> TB count            715634/2684354
> TB hash buckets     8192/8192 (100.00% head buckets used)
> TB hash occupancy   98.30% avg chain occ. Histogram: [95.3,95.8)%|▁▁▃▄▃▄▁▇▁█|[99.5,100.0]%
> TB hash avg chain   22.070 buckets. Histogram: [15.0,16.7)|▁▂▅▄█▅▁▁▁▁|[30.3,32.0]
>
> Acked-by: Sergey Fedorov <sergey.fedorov@linaro.org>
> Suggested-by: Richard Henderson <rth@twiddle.net>
> Reviewed-by: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
> Message-Id: <1465412133-3029-16-git-send-email-cota@braap.org>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>   translate-all.c | 36 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
>
> diff --git a/translate-all.c b/translate-all.c
> index b620fcc..e8b88b4 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -1668,6 +1668,10 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
>       int i, target_code_size, max_target_code_size;
>       int direct_jmp_count, direct_jmp2_count, cross_page;
>       TranslationBlock *tb;
> +    struct qht_stats hst;
> +    uint32_t hgram_opts;
> +    size_t hgram_bins;
> +    char *hgram;
>
>       target_code_size = 0;
>       max_target_code_size = 0;
> @@ -1718,6 +1722,38 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
>                   direct_jmp2_count,
>                   tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) /
>                           tcg_ctx.tb_ctx.nb_tbs : 0);
> +
> +    qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst);

Hi Emilio

   If we use kvm accelerator, we will encouter segment fault.

slave:~/.xie # gdb --args qemu-colo/x86_64-softmmu/qemu-system-x86_64 
--enable-kvm -drive driver=qcow2,file.filename=fd16.qcow2 -monitor stdio 
-vnc :1

(qemu) info jit
Translation buffer state:
gen code size       0/0
TB count            0/0
TB avg target size  0 max=0 bytes
TB avg host size    0 bytes (expansion ratio: 0.0)
cross page TB count 0 (0%)
direct jump count   0 (0%) (2 jumps=0 0%)

Program received signal SIGSEGV, Segmentation fault.
0x0000555555c0c432 in qht_statistics_init (ht=0x5555561ddfd0 
<tcg_ctx+240>, stats=0x7fffffffcab0) at util/qht.c:786
786         stats->head_buckets = map->n_buckets;
Program received signal SIGSEGV, Segmentation fault.
0x0000555555c0c432 in qht_statistics_init (ht=0x5555561ddfd0 
<tcg_ctx+240>, stats=0x7fffffffcab0) at util/qht.c:786
786         stats->head_buckets = map->n_buckets;
(gdb) p *ht
$1 = {map = 0x0, lock = {lock = {__data = {__lock = 0, __count = 0, 
__owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 
0x0, __next = 0x0}}, __size =
     '\000' <repeats 39 times>, __align = 0}}, mode = 0}
(gdb)

Thanks
	-Xie
> +
> +    cpu_fprintf(f, "TB hash buckets     %zu/%zu (%0.2f%% head buckets used)\n",
> +                hst.used_head_buckets, hst.head_buckets,
> +                (double)hst.used_head_buckets / hst.head_buckets * 100);
> +
> +    hgram_opts =  QDIST_PR_BORDER | QDIST_PR_LABELS;
> +    hgram_opts |= QDIST_PR_100X   | QDIST_PR_PERCENT;
> +    if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) {
> +        hgram_opts |= QDIST_PR_NODECIMAL;
> +    }
> +    hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
> +    cpu_fprintf(f, "TB hash occupancy   %0.2f%% avg chain occ. Histogram: %s\n",
> +                qdist_avg(&hst.occupancy) * 100, hgram);
> +    g_free(hgram);
> +
> +    hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
> +    hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain);
> +    if (hgram_bins > 10) {
> +        hgram_bins = 10;
> +    } else {
> +        hgram_bins = 0;
> +        hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
> +    }
> +    hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
> +    cpu_fprintf(f, "TB hash avg chain   %0.3f buckets. Histogram: %s\n",
> +                qdist_avg(&hst.chain), hgram);
> +    g_free(hgram);
> +
> +    qht_statistics_destroy(&hst);
> +
>       cpu_fprintf(f, "\nStatistics:\n");
>       cpu_fprintf(f, "TB flush count      %d\n", tcg_ctx.tb_ctx.tb_flush_count);
>       cpu_fprintf(f, "TB invalidate count %d\n",
>

  reply	other threads:[~2016-07-22  8:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 14:26 [Qemu-devel] [PULL 00/15] tb hash improvements Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 01/15] compiler.h: add QEMU_ALIGNED() to enforce struct alignment Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 02/15] seqlock: remove optional mutex Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 03/15] seqlock: rename write_lock/unlock to write_begin/end Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 04/15] include/processor.h: define cpu_relax() Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 05/15] qemu-thread: add simple test-and-set spinlock Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 06/15] exec: add tb_hash_func5, derived from xxhash Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 07/15] tb hash: hash phys_pc, pc, and flags with xxhash Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 08/15] qdist: add module to represent frequency distributions of data Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 09/15] qdist: add test program Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 10/15] qht: QEMU's fast, resizable and scalable Hash Table Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 11/15] qht: add test program Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 12/15] qht: add qht-bench, a performance benchmark Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 13/15] qht: add test-qht-par to invoke qht-bench from 'check' target Richard Henderson
2016-06-10 14:26 ` [Qemu-devel] [PULL 14/15] tb hash: track translated blocks with qht Richard Henderson
2016-08-10 13:36   ` Igor Mammedov
2016-08-10 19:25     ` [Qemu-devel] [PATCH] qht: support resetting an uninitialized qht Emilio G. Cota
2016-08-11  8:43       ` Igor Mammedov
2016-06-10 14:26 ` [Qemu-devel] [PULL 15/15] translate-all: add tb hash bucket info to 'info jit' dump Richard Henderson
2016-07-22  9:04   ` Changlong Xie [this message]
2016-07-22 16:36     ` [Qemu-devel] [PATCH] qht: do not segfault when gathering stats from an uninitialized qht Emilio G. Cota
2016-07-23  7:45       ` Paolo Bonzini
2016-07-23 10:01       ` Peter Maydell
2016-07-23 10:54         ` Paolo Bonzini
2016-07-23 23:09           ` Emilio G. Cota
2016-06-10 15:33 ` [Qemu-devel] [PULL 00/15] tb hash improvements Peter Maydell
2016-06-10 15:57   ` Peter Maydell
2016-06-10 16:34   ` Emilio G. Cota
2016-06-10 16:41     ` Peter Maydell
2016-06-10 19:24       ` Emilio G. Cota
2016-06-11 23:09       ` Richard Henderson

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=5791E191.4010404@cn.fujitsu.com \
    --to=xiecl.fnst@cn.fujitsu.com \
    --cc=cota@braap.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).