From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPBAR-0004Mu-Cd for qemu-devel@nongnu.org; Tue, 11 Aug 2015 11:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPBAO-0002DM-G8 for qemu-devel@nongnu.org; Tue, 11 Aug 2015 11:08:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPBAO-0002DF-AG for qemu-devel@nongnu.org; Tue, 11 Aug 2015 11:08:40 -0400 From: Christopher Covington Date: Tue, 11 Aug 2015 11:08:31 -0400 Message-Id: <1439305712-3957-2-git-send-email-cov@codeaurora.org> In-Reply-To: <1439305712-3957-1-git-send-email-cov@codeaurora.org> References: <1439305712-3957-1-git-send-email-cov@codeaurora.org> Subject: [Qemu-devel] [RFC 1/2] icount: Print instruction count on exit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Christopher Covington When -icount shift=n is in use, print the instruction count when finished. In conjunction with the `time` command, this can be used to calculate how many instructions per second QEMU TCG can translate and execute. The output can also be used to double-check future facilities such as exposing the instruction count to guest/target software through interfaces such as an emulated Performance Monitors Unit. Signed-off-by: Christopher Covington --- cpus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpus.c b/cpus.c index a822ce3..b0bc8ec 100644 --- a/cpus.c +++ b/cpus.c @@ -511,6 +511,13 @@ void cpu_ticks_init(void) vmstate_register(NULL, 0, &vmstate_timers, &timers_state); } +static Notifier icount_exit_notifier; + +static void print_instruction_count(Notifier *notifier, void *data) +{ + printf("Executed %"PRId64" target instructions.\n", cpu_get_icount_raw()); +} + void configure_icount(QemuOpts *opts, Error **errp) { const char *option; @@ -541,6 +548,8 @@ void configure_icount(QemuOpts *opts, Error **errp) if (errno != 0 || *rem_str != '\0' || !strlen(option)) { error_setg(errp, "icount: Invalid shift value"); } + icount_exit_notifier.notify = &print_instruction_count; + qemu_add_exit_notifier(&icount_exit_notifier); use_icount = 1; return; } else if (icount_align_option) { -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project