All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jing Zhang <jingzhangos@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Oliver Upton <oupton@google.com>, KVM <kvm@vger.kernel.org>,
	KVMPPC <kvm-ppc@vger.kernel.org>, Peter Shier <pshier@google.com>,
	David Matlack <dmatlack@google.com>,
	Ben Gardon <bgardon@google.com>,
	Peter Feiner <pfeiner@google.com>
Subject: Re: [PATCH] KVM: stats: Add VM dirty_pages stats for the number of dirty pages
Date: Wed, 11 Aug 2021 13:14:39 -0700	[thread overview]
Message-ID: <CAAdAUtjRBXhsOo6WcAjwoEvB5TsyDr5=C4Kyt8TdDoRktA880g@mail.gmail.com> (raw)
In-Reply-To: <5183cb08-f739-e6a6-f645-3ccbe92d04d8@redhat.com>

On Wed, Aug 11, 2021 at 3:20 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 11/08/21 00:56, Oliver Upton wrote:
> > What if the statistic was 'dirtied_pages', which records the number of
> > pages dirtied in the lifetime of a VM? Userspace could just record the
> > value each time it blows away the dirty bitmaps and subtract that
> > value next time it reads the stat. It would circumvent the need to
> > walk the entire dirty bitmap to keep the statistic sane.
>
> Yeah, that'd be much better also because the "number of dirty pages"
> statistic is not well defined in init-all-dirty mode.
>
> Making it a vCPU stat works in fact, because mark_page_dirty_in_slot is
> only called with kvm_get_running_vcpu() != NULL; see
> kvm_dirty_ring_get() in virt/kvm/dirty_ring.c.
>
> >>
> >> +               if (kvm->dirty_ring_size) {
> >>                         kvm_dirty_ring_push(kvm_dirty_ring_get(kvm),
> >>                                             slot, rel_gfn);
> >> -               else
> >> +               } else {
> >>                         set_bit_le(rel_gfn, memslot->dirty_bitmap);
> >> +                       ++kvm->stat.generic.dirty_pages;
> >> +               }
> >
> > Aren't pages being pushed out to the dirty ring just as dirty?
> >
>
> Yes, they are.
>
> Paolo
>
According to Oliver's idea, let's define the "dirty_pages" as the
number of dirtied pages during the life cycle of a VM to avoid the
overhead caused by walking the entire dirty_bitmap.
I didn't consider the dirty ring in this patch, but will do in the next.
Will still define dirty_pages as a VM scoped stat in the next patch.
From there, we will see if it is necessary to define it as a VCPU
scoped stat. (Both KVM code and user code would be simpler with it
being as a VM scoped stat).

Thanks,
Jing

WARNING: multiple messages have this Message-ID (diff)
From: Jing Zhang <jingzhangos@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Oliver Upton <oupton@google.com>, KVM <kvm@vger.kernel.org>,
	KVMPPC <kvm-ppc@vger.kernel.org>, Peter Shier <pshier@google.com>,
	David Matlack <dmatlack@google.com>,
	Ben Gardon <bgardon@google.com>,
	Peter Feiner <pfeiner@google.com>
Subject: Re: [PATCH] KVM: stats: Add VM dirty_pages stats for the number of dirty pages
Date: Wed, 11 Aug 2021 20:14:39 +0000	[thread overview]
Message-ID: <CAAdAUtjRBXhsOo6WcAjwoEvB5TsyDr5=C4Kyt8TdDoRktA880g@mail.gmail.com> (raw)
In-Reply-To: <5183cb08-f739-e6a6-f645-3ccbe92d04d8@redhat.com>

On Wed, Aug 11, 2021 at 3:20 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 11/08/21 00:56, Oliver Upton wrote:
> > What if the statistic was 'dirtied_pages', which records the number of
> > pages dirtied in the lifetime of a VM? Userspace could just record the
> > value each time it blows away the dirty bitmaps and subtract that
> > value next time it reads the stat. It would circumvent the need to
> > walk the entire dirty bitmap to keep the statistic sane.
>
> Yeah, that'd be much better also because the "number of dirty pages"
> statistic is not well defined in init-all-dirty mode.
>
> Making it a vCPU stat works in fact, because mark_page_dirty_in_slot is
> only called with kvm_get_running_vcpu() != NULL; see
> kvm_dirty_ring_get() in virt/kvm/dirty_ring.c.
>
> >>
> >> +               if (kvm->dirty_ring_size) {
> >>                         kvm_dirty_ring_push(kvm_dirty_ring_get(kvm),
> >>                                             slot, rel_gfn);
> >> -               else
> >> +               } else {
> >>                         set_bit_le(rel_gfn, memslot->dirty_bitmap);
> >> +                       ++kvm->stat.generic.dirty_pages;
> >> +               }
> >
> > Aren't pages being pushed out to the dirty ring just as dirty?
> >
>
> Yes, they are.
>
> Paolo
>
According to Oliver's idea, let's define the "dirty_pages" as the
number of dirtied pages during the life cycle of a VM to avoid the
overhead caused by walking the entire dirty_bitmap.
I didn't consider the dirty ring in this patch, but will do in the next.
Will still define dirty_pages as a VM scoped stat in the next patch.
From there, we will see if it is necessary to define it as a VCPU
scoped stat. (Both KVM code and user code would be simpler with it
being as a VM scoped stat).

Thanks,
Jing

  reply	other threads:[~2021-08-11 20:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 22:32 [PATCH] KVM: stats: Add VM dirty_pages stats for the number of dirty pages Jing Zhang
2021-08-10 22:44 ` Peter Feiner
2021-08-10 22:44   ` Peter Feiner
2021-08-10 22:51   ` Jing Zhang
2021-08-10 22:51     ` Jing Zhang
2021-08-11 22:52   ` Jing Zhang
2021-08-11 22:52     ` Jing Zhang
2021-08-11 23:19     ` Peter Feiner
2021-08-11 23:19       ` Peter Feiner
2021-08-11 23:25       ` Jing Zhang
2021-08-11 23:25         ` Jing Zhang
2021-08-10 22:56 ` Oliver Upton
2021-08-10 22:56   ` Oliver Upton
2021-08-10 23:15   ` Peter Feiner
2021-08-10 23:15     ` Peter Feiner
2021-08-10 23:26     ` Oliver Upton
2021-08-10 23:26       ` Oliver Upton
2021-08-11 10:20   ` Paolo Bonzini
2021-08-11 10:20     ` Paolo Bonzini
2021-08-11 20:14     ` Jing Zhang [this message]
2021-08-11 20:14       ` Jing Zhang
2021-08-11 12:26 ` kernel test robot

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='CAAdAUtjRBXhsOo6WcAjwoEvB5TsyDr5=C4Kyt8TdDoRktA880g@mail.gmail.com' \
    --to=jingzhangos@google.com \
    --cc=bgardon@google.com \
    --cc=dmatlack@google.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pfeiner@google.com \
    --cc=pshier@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 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.