All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Mark Kanda <mark.kanda@oracle.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 0/2] Support fd-based KVM stats
Date: Wed, 20 Oct 2021 09:26:42 +0200	[thread overview]
Message-ID: <45a7173a-19e9-b5b8-7df2-0d494e4af3b6@redhat.com> (raw)
In-Reply-To: <20211019202904.4857-1-mark.kanda@oracle.com>

On 19/10/21 22:29, Mark Kanda wrote:
> This patchset adds QEMU support for querying fd-based KVM stats. The kernel
> support is provided by:
> 
> cb082bfab59a ("KVM: stats: Add fd-based API to read binary stats data")
> 
> Patch 1 adds QMP support; patch 2 adds HMP support.

Hi Mark,

that's awesome, thanks!

Just a couple remarks on the implementation:

1) for QMP, it would be nice to have separate commands for the schema 
and the value.  This is because in the future we could consider passing 
the file descriptor directly to the QMP client; in which case, it would 
still be nicer to have QEMU turn the schema information into something 
more easily consumable.

2) for HMP, it would be nice to have the exponent converted to e.g. 
"nanoseconds" if the KvmStatUnit is seconds.  It's not super important, 
but it would be nice.  Something as simple as

if (kvm_stat->unit == KVM_STAT_UNIT_SECONDS &&
     kvm_stat->exponent >= -9 && kvm_stat->exponent <= 0 &&
     kvm_stat->exponent % 3 == 0 && kvm_stat->base == 10) {
     const char *si_prefix[] = { "", "milli", "micro", "nano" };
     monitor_printf(" %lu %sseconds", val->value,
                    si_prefix[kvm_stat->exponent / -3]);
} else ...

(Yes, this is nitpicking; but in practice nanoseconds are the only case 
where currently the exponent is not 0, so...).

3) more recent versions of Linux also support histograms, for which you 
have to include the bucket size and the kind (logarithmic/linear) in 
QMP.  For HMP it would be nice to have it printed as

     halt_wait_hist: [1 nanosecond]=200 [2]=30 [4]=50 [8]=120

but, for the first version, it's also okay if the QMP commands just 
skips unknown KVM_STATS_TYPE values altogether.

Paolo

> Mark Kanda (2):
>    qmp: Support fd-based KVM stats query
>    hmp: Support fd-based KVM stats query
> 
>   accel/kvm/kvm-all.c   | 246 ++++++++++++++++++++++++++++++++++++++++++
>   hmp-commands-info.hx  |  13 +++
>   include/monitor/hmp.h |   1 +
>   monitor/hmp-cmds.c    |  52 +++++++++
>   qapi/misc.json        |  73 +++++++++++++
>   5 files changed, 385 insertions(+)
> 



      parent reply	other threads:[~2021-10-20  7:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 20:29 [PATCH 0/2] Support fd-based KVM stats Mark Kanda
2021-10-19 20:29 ` [PATCH 1/2] qmp: Support fd-based KVM stats query Mark Kanda
2021-10-20  7:39   ` Paolo Bonzini
2021-10-19 20:29 ` [PATCH 2/2] hmp: " Mark Kanda
2021-10-20  7:26 ` Paolo Bonzini [this message]

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=45a7173a-19e9-b5b8-7df2-0d494e4af3b6@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mark.kanda@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.