virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio-balloon spec: rework VIRTIO_BALLOON_F_MUST_TELL_HOST feature, support silent deflation
Date: Tue, 28 May 2013 18:09:56 +0300	[thread overview]
Message-ID: <20130528150956.GA28874@redhat.com> (raw)
In-Reply-To: <51A4C00C.6020707@redhat.com>

On Tue, May 28, 2013 at 04:32:44PM +0200, Paolo Bonzini wrote:
> Il 28/05/2013 16:29, Michael S. Tsirkin ha scritto:
> > On Tue, May 28, 2013 at 04:06:02PM +0200, Paolo Bonzini wrote:
> >> Il 28/05/2013 15:32, Michael S. Tsirkin ha scritto:
> >>> At this point I am confused. I think there are two changes in your patch:
> >>>
> >>> 1. Handling of VIRTIO_F_GUEST_MUST_TELL_HOST
> >>>  Is this functionally identical to what I proposed?
> >>>  If yes, I am fine with either change being applied.
> >>
> >> Yes.
> >>
> >>> 2. New SILENT_DEFLATE feature
> >>>  Since guest can get same functionality by not acking
> >>>  TELL_HOST, I still don't see what good it does:
> >>>  Historically a host with no features supports silent
> >>>  deflate and guest with no features can do silent deflate.
> >>>  I conclude silent deflate is the default behaviour for
> >>>  both host and guest, and we can't change default without
> >>>  breaking compatibility.
> >>
> >> You're right that for correctness the existing feature is enough:
> >> if it is not negotiated by the guest, the host ensures correctness by
> >> only giving the guest a fake balloon.
> >>
> >> However, the new feature is about optimization, not correctness.
> >> In fact, VIRTIO_BALLOON_F_SILENT_DEFLATE is the optimization
> >> feature that VIRTIO_BALLOON_F_MUST_TELL_HOST was meant to be.
> >>
> >> What I'm interested in, is drivers that can _optionally_ use silent 
> >> deflation (as an optimization).  These should not get a fake balloon!
> >>
> >> With the new feature bit, these drivers should propose both
> >> VIRTIO_BALLOON_F_GUEST_TELLS_HOST and VIRTIO_BALLOON_F_SILENT_DEFLATE.
> >> The driver can then use silent  deflation if and only if the host
> >> has negotiated  VIRTIO_BALLOON_F_SILENT_DEFLATE too.  Like this:
> >>
> >> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> >> index bd3ae32..05fe948 100644
> >> --- a/drivers/virtio/virtio_balloon.c
> >> +++ b/drivers/virtio/virtio_balloon.c
> >> @@ -186,12 +186,8 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
> >>  		vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
> >>  	}
> >>  
> >> -	/*
> >> -	 * Note that if
> >> -	 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
> >> -	 * is true, we *have* to do it in this order
> >> -	 */
> >> -	tell_host(vb, vb->deflate_vq);
> >> +	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_SILENT_DEFLATE)
> >> +		tell_host(vb, vb->deflate_vq);
> >>  	mutex_unlock(&vb->balloon_lock);
> >>  	release_pages_by_pfn(vb->pfns, vb->num_pfns);
> >>  }
> >> @@ -543,6 +539,7 @@ static int virtballoon_restore(struct virtio_device *vdev)
> >>  static unsigned int features[] = {
> >>  	VIRTIO_BALLOON_F_MUST_TELL_HOST,
> >>  	VIRTIO_BALLOON_F_STATS_VQ,
> >> +	VIRTIO_BALLOON_F_SILENT_DEFLATE,
> >>  };
> >>  
> >>  static struct virtio_driver virtio_balloon_driver = {
> >>
> >>
> >> Of course with the current implementation of the balloon it does not
> >> matter much.  But for example, with Luiz's work, releasing pages as soon
> >> as the shrinker is called will increase effectiveness of the shrinker.
> >> At the same time, not all is lost if the guest prefers not to allow
> >> silent deflation (e.g. because there is an assigned device).
> >>
> >> On old hosts, a guest that can optionally use silent deflation will
> >> not use it.  That's the same as for any other feature bit.
> >>
> >>> How about splitting the patches so we can discuss them separately?
> >>
> >> I can do that, but I hope the above clarifies it.
> > 
> > Maybe I'm just dense.
> > Let's see the split spec patchset?
> 
> What's unclear exactly?  I'm not sure the spec patchset improves things
> that much, I can split it in two or three (change old feature, add new
> feature, add explanation) but it's not like changing logic in a program.
> 
> Paolo

Both your code and what you say here about the new bit seem to break
compatibility with old hosts and guests.
Again, could be just me seeing things.
If it's in spec, I think it would be clearer what are we trying to
achieve, and how.

-- 
MST

  parent reply	other threads:[~2013-05-28 15:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-08 10:10 [PATCH] virtio-balloon spec: rework VIRTIO_BALLOON_F_MUST_TELL_HOST feature, support silent deflation Paolo Bonzini
2013-05-27 15:55 ` Paolo Bonzini
     [not found] ` <51A381D9.5010800@redhat.com>
2013-05-27 16:04   ` Michael S. Tsirkin
     [not found]   ` <20130527160437.GA18270@redhat.com>
2013-05-27 16:09     ` Paolo Bonzini
2013-05-27 17:02       ` Michael S. Tsirkin
2013-05-28  8:38         ` Paolo Bonzini
2013-05-28 10:45           ` Michael S. Tsirkin
     [not found]           ` <20130528104503.GD5467@redhat.com>
2013-05-28 11:13             ` Paolo Bonzini
2013-05-28 11:44               ` Michael S. Tsirkin
2013-05-28 12:04                 ` Paolo Bonzini
2013-05-28 13:32                   ` Michael S. Tsirkin
2013-05-28 14:06                     ` Paolo Bonzini
2013-05-28 14:29                       ` Michael S. Tsirkin
2013-05-28 14:32                         ` Paolo Bonzini
     [not found]                         ` <51A4C00C.6020707@redhat.com>
2013-05-28 15:09                           ` Michael S. Tsirkin [this message]
2013-05-28 16:23                             ` Paolo Bonzini
2013-05-28 16:50                               ` Michael S. Tsirkin
2013-05-28 16:57                                 ` Paolo Bonzini

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=20130528150956.GA28874@redhat.com \
    --to=mst@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=virtualization@lists.linux-foundation.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 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).