From: vandersonmr <vandersonmr2@gmail.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Riku Voipio <riku.voipio@iki.fi>,
vandersonmr <vandersonmr2@gmail.com>,
Laurent Vivier <laurent@vivier.eu>,
Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution counter.
Date: Fri, 14 Jun 2019 10:53:29 -0300 [thread overview]
Message-ID: <20190614135332.12777-2-vandersonmr2@gmail.com> (raw)
In-Reply-To: <20190614135332.12777-1-vandersonmr2@gmail.com>
An uint64_t counter was added in the TranslationBlock struct and
it is incremented every time that the TB is executed.
Signed-off-by: vandersonmr <vandersonmr2@gmail.com>
---
accel/tcg/tcg-runtime.c | 6 ++++++
accel/tcg/tcg-runtime.h | 2 ++
include/exec/exec-all.h | 1 +
include/exec/gen-icount.h | 7 +++++++
linux-user/main.c | 1 +
vl.c | 1 +
6 files changed, 18 insertions(+)
diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c
index 8a1e408e31..d1f4127d31 100644
--- a/accel/tcg/tcg-runtime.c
+++ b/accel/tcg/tcg-runtime.c
@@ -167,3 +167,9 @@ void HELPER(exit_atomic)(CPUArchState *env)
{
cpu_loop_exit_atomic(env_cpu(env), GETPC());
}
+
+void HELPER(inc_exec_freq)(void *ptr)
+{
+ TranslationBlock* tb = (TranslationBlock*) ptr;
+ atomic_inc(&tb->exec_freq);
+}
diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h
index 4fa61b49b4..bf0b75dbe8 100644
--- a/accel/tcg/tcg-runtime.h
+++ b/accel/tcg/tcg-runtime.h
@@ -28,6 +28,8 @@ DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env)
DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env)
+DEF_HELPER_FLAGS_1(inc_exec_freq, TCG_CALL_NO_RWG, void, ptr)
+
#ifdef CONFIG_SOFTMMU
DEF_HELPER_FLAGS_5(atomic_cmpxchgb, TCG_CALL_NO_WG,
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 16034ee651..a80407622e 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -342,6 +342,7 @@ struct TranslationBlock {
uint32_t flags; /* flags defining in which context the code was generated */
uint16_t size; /* size of target code for this block (1 <=
size <= TARGET_PAGE_SIZE) */
+ uint64_t exec_freq;
uint16_t icount;
uint32_t cflags; /* compile flags */
#define CF_COUNT_MASK 0x00007fff
diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h
index f7669b6841..a540d12005 100644
--- a/include/exec/gen-icount.h
+++ b/include/exec/gen-icount.h
@@ -6,11 +6,18 @@
/* Helpers for instruction counting code generation. */
static TCGOp *icount_start_insn;
+extern bool enable_freq_count;
static inline void gen_tb_start(TranslationBlock *tb)
{
TCGv_i32 count, imm;
+ if (enable_freq_count) {
+ TCGv_ptr tb_ptr = tcg_temp_new_ptr();
+ tcg_gen_trunc_i64_ptr(tb_ptr, tcg_const_i64((int64_t) tb));
+ gen_helper_inc_exec_freq(tb_ptr);
+ }
+
tcg_ctx->exitreq_label = gen_new_label();
if (tb_cflags(tb) & CF_USE_ICOUNT) {
count = tcg_temp_local_new_i32();
diff --git a/linux-user/main.c b/linux-user/main.c
index a59ae9439d..1bf7155670 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -58,6 +58,7 @@ static const char *seed_optarg;
unsigned long mmap_min_addr;
unsigned long guest_base;
int have_guest_base;
+bool enable_freq_count = false;
/*
* When running 32-on-64 we should make sure we can fit all of the possible
diff --git a/vl.c b/vl.c
index 005468cbfb..cb6c0ad63d 100644
--- a/vl.c
+++ b/vl.c
@@ -190,6 +190,7 @@ bool boot_strict;
uint8_t *boot_splash_filedata;
int only_migratable; /* turn it off unless user states otherwise */
bool wakeup_suspend_enabled;
+bool enable_freq_count = false;
int icount_align_option;
--
2.22.0
next prev parent reply other threads:[~2019-06-14 14:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 13:53 [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency vandersonmr
2019-06-14 13:53 ` vandersonmr [this message]
2019-06-17 2:28 ` [Qemu-devel] [Qemu-Devel][PATCH 1/3] Adding an optional tb execution counter Richard Henderson
2019-06-17 10:01 ` Alex Bennée
2019-06-14 13:53 ` [Qemu-devel] [Qemu-Devel][PATCH 2/3] Saving counters between tb_flush events vandersonmr
2019-06-17 2:52 ` Richard Henderson
2019-06-17 10:00 ` Alex Bennée
2019-06-14 13:53 ` [Qemu-devel] [Qemu-Devel][PATCH 3/3] Adding command line option to linux-user vandersonmr
2019-06-17 2:54 ` Richard Henderson
2019-06-17 11:30 ` Alex Bennée
2019-06-14 16:01 ` [Qemu-devel] [PATCH 0/3] Collecting TB Execution Frequency no-reply
2019-06-17 10:17 ` Alex Bennée
2019-06-17 13:13 ` 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=20190614135332.12777-2-vandersonmr2@gmail.com \
--to=vandersonmr2@gmail.com \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--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).