kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jing Zhang <jingzhangos@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: KVM <kvm@vger.kernel.org>, KVMPPC <kvm-ppc@vger.kernel.org>,
	Sean Christopherson <seanjc@google.com>,
	Jim Mattson <jmattson@google.com>,
	Peter Shier <pshier@google.com>, Oliver Upton <oupton@google.com>,
	David Rientjes <rientjes@google.com>,
	David Matlack <dmatlack@google.com>
Subject: Re: [PATCH v1 1/4] KVM: stats: Support linear and logarithmic histogram statistics
Date: Fri, 30 Jul 2021 10:31:43 -0700	[thread overview]
Message-ID: <CAAdAUtiC9D=LkZTFDNMUfPXFGAbVvdEvXWAJSznZYA_T7KB8_A@mail.gmail.com> (raw)
In-Reply-To: <8b6f442e-c8bd-d175-471e-6e28b4548c3e@redhat.com>

On Wed, Jul 28, 2021 at 5:39 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 06/07/21 20:03, Jing Zhang wrote:
> > +#define LINHIST_SIZE_SMALL           10
> > +#define LINHIST_SIZE_MEDIUM          20
> > +#define LINHIST_SIZE_LARGE           50
> > +#define LINHIST_SIZE_XLARGE          100
> > +#define LINHIST_BUCKET_SIZE_SMALL    10
> > +#define LINHIST_BUCKET_SIZE_MEDIUM   100
> > +#define LINHIST_BUCKET_SIZE_LARGE    1000
> > +#define LINHIST_BUCKET_SIZE_XLARGE   10000
> > +
> > +#define LOGHIST_SIZE_SMALL           8
> > +#define LOGHIST_SIZE_MEDIUM          16
> > +#define LOGHIST_SIZE_LARGE           32
> > +#define LOGHIST_SIZE_XLARGE          64
> > +#define LOGHIST_BASE_2                       2
>
> I'd prefer inlining all of these.  For log histograms use 2 directly in
> STATS_DESC_LOG_HIST, since the update function below uses fls64.
>
Sure, will inline these values.
Will remove the loghist base, since base 2 log is enough for any
number. No other base is needed.
> >
> > + */
> > +void kvm_stats_linear_hist_update(u64 *data, size_t size,
> > +                               u64 value, size_t bucket_size)
> > +{
> > +     size_t index = value / bucket_size;
> > +
> > +     if (index >= size)
> > +             index = size - 1;
> > +     ++data[index];
> > +}
> > +
>
> Please make this function always inline, so that the compiler optimizes
> the division.
Sure.
>
> Also please use array_index_nospec to clamp the index to the size, in
> case value comes from a memory access as well.  Likewise for
> kvm_stats_log_hist_update.
Thanks. Will do.
>
> Paolo
>

Jing

  reply	other threads:[~2021-07-30 17:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 18:03 [PATCH v1 0/4] Linear and Logarithmic histogram statistics Jing Zhang
2021-07-06 18:03 ` [PATCH v1 1/4] KVM: stats: Support linear and logarithmic " Jing Zhang
2021-07-08 21:01   ` David Matlack
2021-07-08 21:40     ` Jing Zhang
2021-07-08 21:45       ` David Matlack
2021-07-12 14:10   ` kernel test robot
2021-07-12 16:16     ` Jing Zhang
2021-07-12 18:53   ` kernel test robot
2021-07-28 12:39   ` Paolo Bonzini
2021-07-30 17:31     ` Jing Zhang [this message]
2021-07-06 18:03 ` [PATCH v1 2/4] KVM: stats: Update doc for " Jing Zhang
2021-07-07 23:31   ` David Matlack
2021-07-08 14:29     ` Jing Zhang
2021-07-28 12:42     ` Paolo Bonzini
2021-07-30 17:32       ` Jing Zhang
2021-07-08 21:14   ` David Matlack
2021-07-08 21:16     ` David Matlack
2021-07-08 21:43       ` Jing Zhang
2021-07-06 18:03 ` [PATCH v1 3/4] KVM: selftests: Add checks for histogram stats parameters Jing Zhang
2021-07-08 21:26   ` David Matlack
2021-07-06 18:03 ` [PATCH v1 4/4] KVM: stats: Add halt polling related histogram stats Jing Zhang
2021-07-08 21:42   ` David Matlack
2021-07-09 15:18     ` Jing Zhang
2021-07-09 15:25       ` David Matlack
2021-07-28 12:45   ` Paolo Bonzini
2021-07-30 17:34     ` Jing Zhang

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='CAAdAUtiC9D=LkZTFDNMUfPXFGAbVvdEvXWAJSznZYA_T7KB8_A@mail.gmail.com' \
    --to=jingzhangos@google.com \
    --cc=dmatlack@google.com \
    --cc=jmattson@google.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    /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).