From patchwork Wed Sep 9 18:07:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 33221 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 2F7AFB6F34 for ; Thu, 10 Sep 2009 04:20:49 +1000 (EST) Received: from localhost ([127.0.0.1]:55301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlRmf-0005AQ-JL for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 14:20:45 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlRZv-0007Ma-LE for qemu-devel@nongnu.org; Wed, 09 Sep 2009 14:07:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlRZr-0007Ki-Nn for qemu-devel@nongnu.org; Wed, 09 Sep 2009 14:07:35 -0400 Received: from [199.232.76.173] (port=49136 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlRZr-0007KZ-I2 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 14:07:31 -0400 Received: from mail-ew0-f221.google.com ([209.85.219.221]:33946) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlRZq-000886-Th for qemu-devel@nongnu.org; Wed, 09 Sep 2009 14:07:31 -0400 Received: by ewy21 with SMTP id 21so626303ewy.8 for ; Wed, 09 Sep 2009 11:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=TDe+dxPYn+wvT65zYeXG27jCfQR0RmXN5K8xQaX49/Y=; b=FM7ZLIWXQb2CLkLcLP4fEvPcSLB5ntCCT/9q3NMvkK/0ixs2ejWLJAjgR35B9fIul9 QgAZq+pytMz5YdO3wNoaagHp8yr+L04MWJFgcLN+6Ew0RUvO0O/XGyGlJLuu+DbYZVOv pEoiJPldAIljvLt1H7FN5MGP2OjBwtw/YlcmE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=dsv0ctlS74BiUWbR6dgTS2ZJi+WkpKwt/D+wAKlv+OCZwvLR8sykulRd5GmRMSbtzz fSJ6XHG//tsxS/ERv461DbbIYidMNIqn3DRWplkUNie3MabljPSx19WACOQ2VS4wrhYv xrRcFhCW3uJGZDssqM40JWDS5HYECeiRuF3D4= MIME-Version: 1.0 Received: by 10.211.154.10 with SMTP id g10mr547361ebo.49.1252519650162; Wed, 09 Sep 2009 11:07:30 -0700 (PDT) From: Blue Swirl Date: Wed, 9 Sep 2009 21:07:10 +0300 Message-ID: To: qemu-devel X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 5/5] 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 | 15 --------------- qemu-monitor.hx | 2 -- target-ppc/cpu.h | 2 ++ target-ppc/helper.c | 4 ++++ target-ppc/translate.c | 45 ++++++++++++++++++++++++++++++--------------- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index 1a6a812..de65fb8 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -752,9 +752,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 202c457..be141ed 100644 --- a/monitor.c +++ b/monitor.c @@ -420,17 +420,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 - static void do_quit(Monitor *mon, const QDict *qdict) { exit(0); @@ -1872,10 +1861,6 @@ static const mon_cmd_t info_cmds[] = { "", "show the current VM name" }, { "uuid", "", do_info_uuid, "", "show the current VM UUID" }, -#if defined(TARGET_PPC) - { "cpustats", "", do_info_cpu_stats, - "", "show CPU statistics", }, -#endif #if defined(CONFIG_SLIRP) { "usernet", "", do_info_usernet, "", "show user network stack connection states", }, diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 26f9cf7..8720c81 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -73,8 +73,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 27f523f..3cb0424 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -827,6 +827,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 5c85c61..158ef20 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -2813,6 +2813,10 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model) cpu_ppc_register_internal(env, def); cpu_ppc_reset(env); +#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 1c54fa7..c571629 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 @@ -8898,11 +8899,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; @@ -8919,32 +8920,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,