qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RFC 8/9] KVM: Add dirty-ring-size property


From: Peter Xu
Subject: Re: [PATCH RFC 8/9] KVM: Add dirty-ring-size property
Date: Thu, 26 Mar 2020 12:03:26 -0400

On Thu, Mar 26, 2020 at 01:41:44PM +0000, Dr. David Alan Gilbert wrote:
> * Peter Xu (address@hidden) wrote:
> > On Wed, Mar 25, 2020 at 08:00:31PM +0000, Dr. David Alan Gilbert wrote:
> > > > @@ -2077,6 +2079,33 @@ static int kvm_init(MachineState *ms)
> > > >      s->memory_listener.listener.coalesced_io_add = 
> > > > kvm_coalesce_mmio_region;
> > > >      s->memory_listener.listener.coalesced_io_del = 
> > > > kvm_uncoalesce_mmio_region;
> > > >  
> > > > +    /*
> > > > +     * Enable KVM dirty ring if supported, otherwise fall back to
> > > > +     * dirty logging mode
> > > > +     */
> > > > +    if (s->kvm_dirty_ring_size > 0) {
> > > > +        /* Read the max supported pages */
> > > > +        ret = kvm_vm_check_extension(kvm_state, 
> > > > KVM_CAP_DIRTY_LOG_RING);
> > > > +        if (ret > 0) {
> > > > +            if (s->kvm_dirty_ring_size > ret) {
> > > > +                error_report("KVM dirty ring size %d too big (maximum 
> > > > is %d). "
> > > > +                             "Please use a smaller value.",
> > > > +                             s->kvm_dirty_ring_size, ret);
> > > > +                goto err;
> > > > +            }
> > > > +
> > > > +            ret = kvm_vm_enable_cap(s, KVM_CAP_DIRTY_LOG_RING, 0,
> > > > +                                    s->kvm_dirty_ring_size);
> > > > +            if (ret) {
> > > > +                error_report("Enabling of KVM dirty ring failed: %d", 
> > > > ret);
> > > > +                goto err;
> > > > +            }
> > > > +
> > > > +            s->kvm_dirty_gfn_count =
> > > > +                s->kvm_dirty_ring_size / sizeof(struct kvm_dirty_gfn);
> > > 
> > > What happens if I was to pass dirty-ring-size=1 ?
> > > Then the count would be 0 and things would get upset somewhere?
> > > Do you need to check for a minimum postive value?
> > 
> > The above kvm_vm_enable_cap() should fail directly and QEMU will stop.
> > Yes we should check it, but kernel will do that in all cases, so I
> > just didn't do that explicitly again in the userspace.
> 
> We probably should have that check since you can give them a more
> obvious error message.

Yes we can.  Or I can enhance the error message when we failed with
kvm_vm_enable_cap() so the user will get the important hints.  I think
maybe that's more important than the explicit check itself.

> 
> > I was planning this to be an advanced feature so the user of this
> > parameter should know the rules to pass values in.
> 
> Advanced users just make advanced mistakes :-)
> 
> I did wonder if perhaps this option should be a count of entries rather
> than a byte size.

Sometimes it's easier to know "how many bytes we used", while instead
sometimes we want to know "how many dirty addresses we can track".
But sure I can switch, considering the users might be more interested
in the latter. :)

Thanks,

-- 
Peter Xu




reply via email to

[Prev in Thread] Current Thread [Next in Thread]