From patchwork Fri Jun 10 14:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9169949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 98C9D604DB for ; Fri, 10 Jun 2016 14:37:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8726A28210 for ; Fri, 10 Jun 2016 14:37:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77EDE28366; Fri, 10 Jun 2016 14:37:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EEC3B28210 for ; Fri, 10 Jun 2016 14:37:23 +0000 (UTC) Received: from localhost ([::1]:41452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNYp-0003dv-4G for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Jun 2016 10:37:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOs-0003hO-Ju for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBNOr-0005jk-7y for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:06 -0400 Received: from mail-pa0-x244.google.com ([2607:f8b0:400e:c03::244]:33456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOq-0005jR-Ul for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:05 -0400 Received: by mail-pa0-x244.google.com with SMTP id di3so5191198pab.0 for ; Fri, 10 Jun 2016 07:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1zcyq4Ep0DdXYSkEUbtPk5pao/37PekZLWysZHe+ntI=; b=d6gm4ZqUj7Ef45FAo2YwFD9yqw2OXgx7HryazWFmWYVsnJHpC9Psoe0wviqO7VfHw/ aLlBnNPS0ccZKaE80v/0sBFoTrvXKoMZa7Gs/kzv2JOEYslDF6DdYDu5WS1/OCzw4COo CjbaY9XHk0VX5m18RMT4oR/Piu2Y2CX6Y0zjx5LS/0+3Nnzb5zESfXeOvuTrt8dSuoXE jH6PvJTVGPKsQBlNy2Vh3mOw2u5GOAg76OH6KRJ21uqzABIeMc8PGoW4NAcKDwY9702g mhdWk+VVGR8M2reEQKnGFPVkYE4Rc8ylYXTX4cGM8G1LRvrS0sj32q35QX2lNOC6QWM/ BZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1zcyq4Ep0DdXYSkEUbtPk5pao/37PekZLWysZHe+ntI=; b=LtNwS2C5Li3ZSwphL1kLG2yZmxyIa9D6mGByAkF9gtFegs44IDU+SVsTAAqGMw+0Ec UalVeEZQW3FklR0THwFAysObwc9hTT95MOv5iLNsD/qfGCthhhkFem8QQnH9+OrAGZQi qxlrGuOsP+55GgksCP3H4dfetzx1NbViw5LtbaAQ1eY7GXweu7umTV6GWA4u4GgY/CzV YmUUiB546HFRFSbrWfknyZh4qwycy7yOeunyATMHmgzu9KSlTpgEflAqz498NjWq+oAk DwhV4GXkeNBHL9zgJnPMVBi2zmySpxrTV5nkIJEWfcl9ykG7cVLw+MDJWM2SPT3dqHMe +oeA== X-Gm-Message-State: ALyK8tLK0dRvohBCyoobhhg/wL1DKiZnGQx0251AzmDqXQX93KuQaO0U76dquc6/Wn37GA== X-Received: by 10.66.220.168 with SMTP id px8mr2518123pac.83.1465568824290; Fri, 10 Jun 2016 07:27:04 -0700 (PDT) Received: from anchor.twiddle.net (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id vy8sm18227219pab.22.2016.06.10.07.27.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 07:27:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 Jun 2016 07:26:53 -0700 Message-Id: <1465568813-19771-16-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465568813-19771-1-git-send-email-rth@twiddle.net> References: <1465568813-19771-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::244 Subject: [Qemu-devel] [PULL 15/15] translate-all: add tb hash bucket info to 'info jit' dump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" 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 Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <1465412133-3029-16-git-send-email-cota@braap.org> Signed-off-by: Richard Henderson --- 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); + + 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",