qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: vandersonmr <vandersonmr2@gmail.com>
To: qemu-devel@nongnu.org
Cc: vandersonmr <vandersonmr2@gmail.com>
Subject: [Qemu-devel] [PATCH v4 5/7] log: adding -d tb_stats to control tbstats
Date: Fri, 19 Jul 2019 22:02:33 -0300	[thread overview]
Message-ID: <20190720010235.32444-6-vandersonmr2@gmail.com> (raw)
In-Reply-To: <20190720010235.32444-1-vandersonmr2@gmail.com>

Adding -d tb_stats:[limit:[all|jit|exec]] to control TBStatistics
collection. "limit" is used to limit the number of TBStats in the
linux-user dump. [all|jit|exec] control the profilling level used
by the TBStats: all, only jit stats or only execution count stats.

Signed-off-by: Vanderson M. do Rosario <vandersonmr2@gmail.com>
---
 include/qemu/log.h |  1 +
 util/log.c         | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/qemu/log.h b/include/qemu/log.h
index 8cdfc268ca..93642603e5 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void)
 /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
 #define CPU_LOG_TB_OP_IND  (1 << 16)
 #define CPU_LOG_TB_FPU     (1 << 17)
+#define CPU_LOG_TB_STATS   (1 << 18)
 
 /* Lock output for a series of related logs.  Since this is not needed
  * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
diff --git a/util/log.c b/util/log.c
index f81653d712..8109d19afb 100644
--- a/util/log.c
+++ b/util/log.c
@@ -30,6 +30,7 @@ FILE *qemu_logfile;
 int qemu_loglevel;
 static int log_append = 0;
 static GArray *debug_regions;
+int32_t max_num_hot_tbs_to_dump;
 
 /* Return the number of characters emitted.  */
 int qemu_log(const char *fmt, ...)
@@ -273,6 +274,8 @@ const QEMULogItem qemu_log_items[] = {
     { CPU_LOG_TB_NOCHAIN, "nochain",
       "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
       "complete traces" },
+    { CPU_LOG_TB_STATS, "tb_stats[:limit:(all,jit,exec)]",
+      "show TBs statistics (until given a limit) ordered by their hotness.\n" },
     { 0, NULL, NULL },
 };
 
@@ -294,6 +297,37 @@ int qemu_str_to_log_mask(const char *str)
             trace_enable_events((*tmp) + 6);
             mask |= LOG_TRACE;
 #endif
+        } else if (g_str_has_prefix(*tmp, "tb_stats")) {
+            if (g_str_has_prefix(*tmp, "tb_stats:") && (*tmp)[9] != '\0') {
+
+                if (!g_ascii_isdigit(*((*tmp) + 9))) {
+                    fprintf(stderr,
+                            "should be a number follow by [all|jit|exec], as tb_stats:10:all\n");
+                    exit(1);
+                }
+                /* get limit */
+                max_num_hot_tbs_to_dump = atoi((*tmp) + 9);
+
+                /* get profilling level */
+                char *s = (*tmp) + 9;
+                while (*s != '\0') {
+                    if (*s++ == ':') {
+                        break;
+                    }
+                }
+                if (g_str_equal(s, "jit") == 0) {
+                    set_default_tbstats_flag(TB_JIT_STATS);
+                } else if (g_str_equal(s, "exec") == 0) {
+                    set_default_tbstats_flag(TB_EXEC_STATS);
+                } else {
+                    set_default_tbstats_flag(TB_JIT_STATS | TB_EXEC_STATS);
+                }
+            } else {
+                set_default_tbstats_flag(TB_JIT_STATS | TB_EXEC_STATS);
+            }
+
+            mask |= CPU_LOG_TB_STATS;
+            enable_collect_tb_stats();
         } else {
             for (item = qemu_log_items; item->mask != 0; item++) {
                 if (g_str_equal(*tmp, item->name)) {
-- 
2.22.0



  parent reply	other threads:[~2019-07-20  1:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-20  1:02 [Qemu-devel] [PATCH v4 0/7] Measure Tiny Code Generation Quality vandersonmr
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 1/7] accel: introducing TBStatistics structure vandersonmr
2019-07-26 11:56   ` Alex Bennée
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 2/7] accel: collecting TB execution count vandersonmr
2019-07-26 13:38   ` Alex Bennée
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 3/7] accel: collecting JIT statistics vandersonmr
2019-07-26 14:46   ` Alex Bennée
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 4/7] accel: replacing part of CONFIG_PROFILER with TBStats vandersonmr
2019-07-26 15:25   ` Alex Bennée
2019-07-20  1:02 ` vandersonmr [this message]
2019-07-26 16:20   ` [Qemu-devel] [PATCH v4 5/7] log: adding -d tb_stats to control tbstats Alex Bennée
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 6/7] monitor: adding tb_stats hmp command vandersonmr
2019-07-26 16:57   ` Alex Bennée
2019-07-20  1:02 ` [Qemu-devel] [PATCH v4 7/7] monitor: adding info tbs, tb, and coverset vandersonmr
2019-07-26 18:17   ` Alex Bennée
2019-07-29 11:01   ` Alex Bennée
2019-07-29 15:20     ` Alex Bennée
2019-07-26 12:51 ` [Qemu-devel] [PATCH v4 0/7] Measure Tiny Code Generation Quality Alex Bennée

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=20190720010235.32444-6-vandersonmr2@gmail.com \
    --to=vandersonmr2@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).