From patchwork Wed May 12 20:57:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 52452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 81F29B7E11 for ; Thu, 13 May 2010 15:29:04 +1000 (EST) Received: from localhost ([127.0.0.1]:45437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCQyh-0004jC-HZ for incoming@patchwork.ozlabs.org; Thu, 13 May 2010 01:28:59 -0400 Received: from [140.186.70.92] (port=40997 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCPFR-0008L5-9D for qemu-devel@nongnu.org; Wed, 12 May 2010 23:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCJpK-0004e8-Ad for qemu-devel@nongnu.org; Wed, 12 May 2010 17:51:21 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:42166) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCJpJ-0004dp-2E for qemu-devel@nongnu.org; Wed, 12 May 2010 17:50:50 -0400 Received: by pvg7 with SMTP id 7so339642pvg.4 for ; Wed, 12 May 2010 14:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=fwc2XMIqcR29AXdqLP3tOzf1Wh8zPB+G7AHd6SjFs3I=; b=c933XooEqIJmCknnuJUznwtLBU2md6bqpcshYFnaztSmgMgPYpba7DKCVO46jTaNcm 8yOw/rYWY/XLDaJ0BexYopm9GhbFEilU0Q+IRTDwtiZnQBWrceY6h0YsYhJMWet3jAja AkK3TPVBi0phA6mw7SKk8BRfyW5bwpDBMtij8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=pkBUARDxkMI1VPZ7Ie3nPItaZiS3kquz4DzjJKECQMF3WslnPaavQerd86/PvHVszk qfqoBy0VFUdGuzriy7rLEH3Ryonvjbl8fFBknMP8+NfhKSQ9gLHKYBdAiHP5ksXzpkSQ unj6YTb7dubgL/OgnpJSqIrlKpyVhvBRNrLyE= MIME-Version: 1.0 Received: by 10.141.188.37 with SMTP id q37mr66430rvp.212.1273697879299; Wed, 12 May 2010 13:57:59 -0700 (PDT) Received: by 10.141.44.12 with HTTP; Wed, 12 May 2010 13:57:59 -0700 (PDT) Date: Wed, 12 May 2010 23:57:59 +0300 Message-ID: From: Blue Swirl To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 4/4] PPC: use device info for CPU statistics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Blue Swirl --- cpu-all.h | 3 --- monitor.c | 19 ------------------- qemu-monitor.hx | 2 -- target-ppc/cpu.h | 2 ++ target-ppc/helper.c | 4 ++++ target-ppc/translate.c | 45 ++++++++++++++++++++++++++++++--------------- 6 files changed, 36 insertions(+), 39 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index 52a1817..767ff18 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -765,9 +765,6 @@ CPUState *qemu_get_cpu(int cpu); void cpu_dump_state(CPUState *env, FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), int flags); -void cpu_dump_statistics (CPUState *env, FILE *f, - int (*cpu_fprintf)(FILE *f, const char *fmt, ...), - int flags); void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); diff --git a/monitor.c b/monitor.c index eed1026..89ed723 100644 --- a/monitor.c +++ b/monitor.c @@ -1012,16 +1012,6 @@ static void do_info_history(Monitor *mon) } } -#if defined(TARGET_PPC) -/* XXX: not implemented in other targets */ -static void do_info_cpu_stats(Monitor *mon) -{ - CPUState *env; - - env = mon_get_cpu(); - cpu_dump_statistics(env, (FILE *)mon, &monitor_fprintf, 0); -} -#endif /** * do_quit(): Quit QEMU execution @@ -2731,15 +2721,6 @@ static const mon_cmd_t info_cmds[] = { .user_print = do_info_uuid_print, .mhandler.info_new = do_info_uuid, }, -#if defined(TARGET_PPC) - { - .name = "cpustats", - .args_type = "", - .params = "", - .help = "show CPU statistics", - .mhandler.info = do_info_cpu_stats, - }, -#endif #if defined(CONFIG_SLIRP) { .name = "usernet", diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 37c733f..5e38bd0 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -100,8 +100,6 @@ show the vnc server status show the current VM name @item info uuid show the current VM UUID -@item info cpustats -show CPU statistics @item info usernet show user network stack connection states @item info migrate diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 2ad4486..088d2cd 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -848,6 +848,8 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) } #endif +void register_stats_handler(const char *name, CPUState *env1); + #include "cpu-all.h" #include "exec-all.h" diff --git a/target-ppc/helper.c b/target-ppc/helper.c index a5479c4..133ece9 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -2825,6 +2825,10 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model) env->cpu_model_str = cpu_model; cpu_ppc_register_internal(env, def); +#if !defined(CONFIG_USER_ONLY) + register_stats_handler(cpu_model, env); +#endif + qemu_init_vcpu(env); return env; diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 86cca51..2d44e7d 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -28,6 +28,7 @@ #include "tcg-op.h" #include "qemu-common.h" #include "host-utils.h" +#include "monitor.h" #include "helper.h" #define GEN_HELPER 1 @@ -8896,11 +8897,11 @@ void cpu_dump_state (CPUState *env, FILE *f, #undef RFPL } -void cpu_dump_statistics (CPUState *env, FILE*f, - int (*cpu_fprintf)(FILE *f, const char *fmt, ...), - int flags) +#if !defined(CONFIG_USER_ONLY) +static void cpu_dump_statistics(Monitor *mon, void *opaque) { #if defined(DO_PPC_STATISTICS) + CPUState *env = opaque; opc_handler_t **t1, **t2, **t3, *handler; int op1, op2, op3; @@ -8917,32 +8918,46 @@ void cpu_dump_statistics (CPUState *env, FILE*f, handler = t3[op3]; if (handler->count == 0) continue; - cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: " - "%016llx %lld\n", - op1, op2, op3, op1, (op3 << 5) | op2, - handler->oname, - handler->count, handler->count); + monitor_printf(mon, "%02x %02x %02x (%02x %04d) %16s: " + "%016" PRIx64 " %" PRId64 "\n", + op1, op2, op3, op1, (op3 << 5) | op2, + handler->oname, + handler->count, handler->count); } } else { if (handler->count == 0) continue; - cpu_fprintf(f, "%02x %02x (%02x %04d) %16s: " - "%016llx %lld\n", - op1, op2, op1, op2, handler->oname, - handler->count, handler->count); + monitor_printf(mon, "%02x %02x (%02x %04d) %16s: " + "%016" PRIx64 " %" PRId64 "\n", + op1, op2, op1, op2, handler->oname, + handler->count, handler->count); } } } else { if (handler->count == 0) continue; - cpu_fprintf(f, "%02x (%02x ) %16s: %016llx %lld\n", - op1, op1, handler->oname, - handler->count, handler->count); + monitor_printf(mon, "%02x (%02x ) %16s: %016" PRIx64 + " %" PRId64 "\n", + op1, op1, handler->oname, + handler->count, handler->count); } } +#else + monitor_printf(mon, "CPU statistics not compiled\n"); #endif } +static const struct MonDevInfo cpu_statistics_info = { + .dev_name = "cpu.stats", + .dev_info_cb = cpu_dump_statistics, +}; + +void register_stats_handler(const char *name, CPUState *env1) +{ + monitor_register_device_info(&cpu_statistics_info, env1); +} +#endif + /*****************************************************************************/ static inline void gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,