From nobody Mon Nov 10 09:47:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528953; cv=none; d=zoho.com; s=zohoarc; b=ZpFDG0Br0Fw2Y22qCnFYIY5Cq15sraNwaUVe905t+lrEOj3+/lnKHpcRF6u/6pejpNHGpY6kEvWmuzgrvff2g1YpUlo1LTGDog5dzPVYD/k2PPepRAvqw7fxqFIct2N/3tAujcmdowDARzFFL+CLS/X8e0uflMD2/Nf35lAn7Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528953; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aOJTVm7iCkar7SIaPVw6hZUOg89zlsvbUA+qk5Hw9rc=; b=j3B/dSPBEV02dwA4pJPfRQYpCCTQi15QRLjU44vphAf21Md0SuSRO0dzJCqgiQotZCeR/p3R6yt9CqYZ3O6K1dBUA8Z3Y/ORSSOVm/aDhZ7gAr6Pw/yR65fFETVILiiFwPbaVM8FoG5nUsjd5Mz2+PuT5MSp4HL9ryM0DCNK8qU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528953668466.05845254457984; Wed, 17 Apr 2019 12:22:33 -0700 (PDT) Received: from localhost ([127.0.0.1]:58351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq8b-0002s6-MV for importer@patchew.org; Wed, 17 Apr 2019 15:22:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq4R-0008O6-BU for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:18:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGq4P-0008Ob-Ai for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:18:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60978) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGq4O-0008MY-SY for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:18:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D5D881129 for ; Wed, 17 Apr 2019 19:18:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0263519C7C; Wed, 17 Apr 2019 19:18:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7A8AB1132B74; Wed, 17 Apr 2019 21:18:05 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:17:52 +0200 Message-Id: <20190417191805.28198-5-armbru@redhat.com> In-Reply-To: <20190417191805.28198-1-armbru@redhat.com> References: <20190417191805.28198-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Apr 2019 19:18:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/17] tcg: Simplify how dump_exec_info() prints 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: dgilbert@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dump_exec_info() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_info_jit() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- accel/tcg/translate-all.c | 45 ++++++++++++++++++++------------------- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 41 ++++++++++++++++++----------------- tcg/tcg.h | 2 +- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 85e80a1fad..75a6cf49f1 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -50,6 +50,7 @@ #include "translate-all.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/main-loop.h" #include "exec/log.h" @@ -2214,8 +2215,7 @@ void tb_flush_jmp_cache(CPUState *cpu, target_ulong a= ddr) tb_jmp_cache_clear_page(cpu, addr); } =20 -static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, - struct qht_stats hst) +static void print_qht_statistics(struct qht_stats hst) { uint32_t hgram_opts; size_t hgram_bins; @@ -2224,7 +2224,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, if (!hst.head_buckets) { return; } - cpu_fprintf(f, "TB hash buckets %zu/%zu (%0.2f%% head buckets used= )\n", + qemu_printf("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); =20 @@ -2234,7 +2234,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, hgram_opts |=3D QDIST_PR_NODECIMAL; } hgram =3D qdist_pr(&hst.occupancy, 10, hgram_opts); - cpu_fprintf(f, "TB hash occupancy %0.2f%% avg chain occ. Histogram: = %s\n", + qemu_printf("TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\= n", qdist_avg(&hst.occupancy) * 100, hgram); g_free(hgram); =20 @@ -2247,7 +2247,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, hgram_opts |=3D QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE; } hgram =3D qdist_pr(&hst.chain, hgram_bins, hgram_opts); - cpu_fprintf(f, "TB hash avg chain %0.3f buckets. Histogram: %s\n", + qemu_printf("TB hash avg chain %0.3f buckets. Histogram: %s\n", qdist_avg(&hst.chain), hgram); g_free(hgram); } @@ -2285,7 +2285,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpoi= nter value, gpointer data) return false; } =20 -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) +void dump_exec_info(void) { struct tb_tree_stats tst =3D {}; struct qht_stats hst; @@ -2294,43 +2294,44 @@ void dump_exec_info(FILE *f, fprintf_function cpu_f= printf) tcg_tb_foreach(tb_tree_stats_iter, &tst); nb_tbs =3D tst.nb_tbs; /* XXX: avoid using doubles ? */ - cpu_fprintf(f, "Translation buffer state:\n"); + qemu_printf("Translation buffer state:\n"); /* * Report total code size including the padding and TB structs; * otherwise users might think "-tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats tho= ugh. */ - cpu_fprintf(f, "gen code size %zu/%zu\n", + qemu_printf("gen code size %zu/%zu\n", tcg_code_size(), tcg_code_capacity()); - cpu_fprintf(f, "TB count %zu\n", nb_tbs); - cpu_fprintf(f, "TB avg target size %zu max=3D%zu bytes\n", + qemu_printf("TB count %zu\n", nb_tbs); + qemu_printf("TB avg target size %zu max=3D%zu bytes\n", nb_tbs ? tst.target_size / nb_tbs : 0, tst.max_target_size); - cpu_fprintf(f, "TB avg host size %zu bytes (expansion ratio: %0.1f)= \n", + qemu_printf("TB avg host size %zu bytes (expansion ratio: %0.1f)\n", nb_tbs ? tst.host_size / nb_tbs : 0, tst.target_size ? (double)tst.host_size / tst.target_size = : 0); - cpu_fprintf(f, "cross page TB count %zu (%zu%%)\n", tst.cross_page, - nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); - cpu_fprintf(f, "direct jump count %zu (%zu%%) (2 jumps=3D%zu %zu%%)\= n", + qemu_printf("cross page TB count %zu (%zu%%)\n", tst.cross_page, + nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); + qemu_printf("direct jump count %zu (%zu%%) (2 jumps=3D%zu %zu%%)\n", tst.direct_jmp_count, nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0, tst.direct_jmp2_count, nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0); =20 qht_statistics_init(&tb_ctx.htable, &hst); - print_qht_statistics(f, cpu_fprintf, hst); + print_qht_statistics(hst); qht_statistics_destroy(&hst); =20 - cpu_fprintf(f, "\nStatistics:\n"); - cpu_fprintf(f, "TB flush count %u\n", + qemu_printf("\nStatistics:\n"); + qemu_printf("TB flush count %u\n", atomic_read(&tb_ctx.tb_flush_count)); - cpu_fprintf(f, "TB invalidate count %zu\n", tcg_tb_phys_invalidate_cou= nt()); + qemu_printf("TB invalidate count %zu\n", + tcg_tb_phys_invalidate_count()); =20 tlb_flush_counts(&flush_full, &flush_part, &flush_elide); - cpu_fprintf(f, "TLB full flushes %zu\n", flush_full); - cpu_fprintf(f, "TLB partial flushes %zu\n", flush_part); - cpu_fprintf(f, "TLB elided flushes %zu\n", flush_elide); - tcg_dump_info(f, cpu_fprintf); + qemu_printf("TLB full flushes %zu\n", flush_full); + qemu_printf("TLB partial flushes %zu\n", flush_part); + qemu_printf("TLB elided flushes %zu\n", flush_elide); + tcg_dump_info(); } =20 void dump_opcount_info(void) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 40f5edf4dc..da07ce311f 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -362,7 +362,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, targe= t_ulong addr) return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); } =20 -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); +void dump_exec_info(void); void dump_opcount_info(void); #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/monitor.c b/monitor.c index 30a7ffe32b..24e4d49d11 100644 --- a/monitor.c +++ b/monitor.c @@ -1318,7 +1318,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *q= dict) return; } =20 - dump_exec_info((FILE *)mon, monitor_fprintf); + dump_exec_info(); dump_drift_info((FILE *)mon, monitor_fprintf); } =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index cc5f4e2a03..6a22c8746c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4015,7 +4015,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } =20 #ifdef CONFIG_PROFILER -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_info(void) { TCGProfile prof =3D {}; const TCGProfile *s; @@ -4029,52 +4029,53 @@ void tcg_dump_info(FILE *f, fprintf_function cpu_fp= rintf) tb_div_count =3D tb_count ? tb_count : 1; tot =3D s->interm_time + s->code_time; =20 - cpu_fprintf(f, "JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n= ", + qemu_printf("JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n", tot, tot / 2.4e9); - cpu_fprintf(f, "translated TBs %" PRId64 " (aborted=3D%" PRId64 "= %0.1f%%)\n",=20 + qemu_printf("translated TBs %" PRId64 " (aborted=3D%" PRId64 + " %0.1f%%)\n", tb_count, s->tb_count1 - tb_count, (double)(s->tb_count1 - s->tb_count) / (s->tb_count1 ? s->tb_count1 : 1) * 100.0); - cpu_fprintf(f, "avg ops/TB %0.1f max=3D%d\n",=20 + qemu_printf("avg ops/TB %0.1f max=3D%d\n", (double)s->op_count / tb_div_count, s->op_count_max); - cpu_fprintf(f, "deleted ops/TB %0.2f\n", + qemu_printf("deleted ops/TB %0.2f\n", (double)s->del_op_count / tb_div_count); - cpu_fprintf(f, "avg temps/TB %0.2f max=3D%d\n", + qemu_printf("avg temps/TB %0.2f max=3D%d\n", (double)s->temp_count / tb_div_count, s->temp_count_max); - cpu_fprintf(f, "avg host code/TB %0.1f\n", + qemu_printf("avg host code/TB %0.1f\n", (double)s->code_out_len / tb_div_count); - cpu_fprintf(f, "avg search data/TB %0.1f\n", + qemu_printf("avg search data/TB %0.1f\n", (double)s->search_out_len / tb_div_count); =20 - cpu_fprintf(f, "cycles/op %0.1f\n",=20 + qemu_printf("cycles/op %0.1f\n", s->op_count ? (double)tot / s->op_count : 0); - cpu_fprintf(f, "cycles/in byte %0.1f\n",=20 + qemu_printf("cycles/in byte %0.1f\n", s->code_in_len ? (double)tot / s->code_in_len : 0); - cpu_fprintf(f, "cycles/out byte %0.1f\n",=20 + qemu_printf("cycles/out byte %0.1f\n", s->code_out_len ? (double)tot / s->code_out_len : 0); - cpu_fprintf(f, "cycles/search byte %0.1f\n", + qemu_printf("cycles/search byte %0.1f\n", s->search_out_len ? (double)tot / s->search_out_len : 0); if (tot =3D=3D 0) { tot =3D 1; } - cpu_fprintf(f, " gen_interm time %0.1f%%\n",=20 + qemu_printf(" gen_interm time %0.1f%%\n", (double)s->interm_time / tot * 100.0); - cpu_fprintf(f, " gen_code time %0.1f%%\n",=20 + qemu_printf(" gen_code time %0.1f%%\n", (double)s->code_time / tot * 100.0); - cpu_fprintf(f, "optim./code time %0.1f%%\n", + qemu_printf("optim./code time %0.1f%%\n", (double)s->opt_time / (s->code_time ? s->code_time : 1) * 100.0); - cpu_fprintf(f, "liveness/code time %0.1f%%\n",=20 + qemu_printf("liveness/code time %0.1f%%\n", (double)s->la_time / (s->code_time ? s->code_time : 1) * 1= 00.0); - cpu_fprintf(f, "cpu_restore count %" PRId64 "\n", + qemu_printf("cpu_restore count %" PRId64 "\n", s->restore_count); - cpu_fprintf(f, " avg cycles %0.1f\n", + qemu_printf(" avg cycles %0.1f\n", s->restore_count ? (double)s->restore_time / s->restore_co= unt : 0); } #else -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_info(void) { - cpu_fprintf(f, "[TCG profiler not compiled]\n"); + qemu_printf("[TCG profiler not compiled]\n"); } #endif =20 diff --git a/tcg/tcg.h b/tcg/tcg.h index 9f2b03f119..a394d78237 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1017,7 +1017,7 @@ int tcg_check_temp_count(void); #endif =20 int64_t tcg_cpu_exec_time(void); -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf); +void tcg_dump_info(void); void tcg_dump_op_count(void); =20 #define TCG_CT_ALIAS 0x80 --=20 2.17.2