From: "Michael S. Tsirkin" <mst@redhat.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
Jeff Epler <jepler@unpythonic.net>, Tejun Heo <tj@kernel.org>,
Jiri Kosina <jkosina@suse.cz>,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] virtio_balloon: Restore the entire balloon after the system freeze
Date: Fri, 1 Jan 2016 12:11:52 +0200 [thread overview]
Message-ID: <20160101121124-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20160101115424-mutt-send-email-mst@redhat.com>
On Fri, Jan 01, 2016 at 12:11:02PM +0200, Michael S. Tsirkin wrote:
> On Fri, Dec 04, 2015 at 02:37:50PM +0100, Petr Mladek wrote:
> > fill_balloon() and leak_balloon() manipulate only a limited number
> > of pages in one call. This is the reason why remove_common() calls
> > leak_balloon() in a while cycle.
> >
> > remove_common() is called also when the system is being frozen.
> > But fill_balloon() is called only once when the system is being
> > restored. It means that most of the balloon stays leaked after
> > the system freeze and restore.
>
> Right, but refilling might take a long while.
> In fact, we sleep for 200msec on refill failure,
> stalling system resume - which is already a bug.
>
> > This patch adds the missing while cycle also into virtballoon_restore().
> > Also it makes fill_balloon() to return the number of really modified
> > pages. Note that leak_balloon() already did this.
> >
> > Signed-off-by: Petr Mladek <pmladek@suse.com>
>
> This is a replacement for:
> virtio_balloon: Restore the entire balloon after the system freeze
oops, typo
I meant to write I'll send a replacement patch shortly :)
> > ---
> > drivers/virtio/virtio_balloon.c | 11 +++++++++--
> > 1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> > index 7efc32945810..d73a86db2490 100644
> > --- a/drivers/virtio/virtio_balloon.c
> > +++ b/drivers/virtio/virtio_balloon.c
> > @@ -135,9 +135,10 @@ static void set_page_pfns(u32 pfns[], struct page *page)
> > pfns[i] = page_to_balloon_pfn(page) + i;
> > }
> >
> > -static void fill_balloon(struct virtio_balloon *vb, size_t num)
> > +static unsigned fill_balloon(struct virtio_balloon *vb, size_t num)
> > {
> > struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
> > + unsigned num_allocated_pages;
> >
> > /* We can only do one array worth at a time. */
> > num = min(num, ARRAY_SIZE(vb->pfns));
> > @@ -162,10 +163,13 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
> > adjust_managed_page_count(page, -1);
> > }
> >
> > + num_allocated_pages = vb->num_pfns;
> > /* Did we get any? */
> > if (vb->num_pfns != 0)
> > tell_host(vb, vb->inflate_vq);
> > mutex_unlock(&vb->balloon_lock);
> > +
> > + return num_allocated_pages;
> > }
> >
> > static void release_pages_balloon(struct virtio_balloon *vb)
> > @@ -581,6 +585,7 @@ static int virtballoon_freeze(struct virtio_device *vdev)
> > static int virtballoon_restore(struct virtio_device *vdev)
> > {
> > struct virtio_balloon *vb = vdev->priv;
> > + s64 diff;
> > int ret;
> >
> > ret = init_vqs(vdev->priv);
> > @@ -589,7 +594,9 @@ static int virtballoon_restore(struct virtio_device *vdev)
> >
> > virtio_device_ready(vdev);
> >
> > - fill_balloon(vb, towards_target(vb));
> > + diff = towards_target(vb);
> > + while (diff > 0)
> > + diff -= fill_balloon(vb, diff);
> > update_balloon_size(vb);
> > return 0;
> > }
> > --
> > 1.8.5.6
next prev parent reply other threads:[~2016-01-01 10:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 13:37 [PATCH v4 0/2] virtio_balloon: Fix restore and convert to workqueue Petr Mladek
2015-12-04 13:37 ` [PATCH v4 1/2] virtio_balloon: Restore the entire balloon after the system freeze Petr Mladek
2016-01-01 10:11 ` Michael S. Tsirkin
2016-01-01 10:11 ` Michael S. Tsirkin [this message]
2015-12-04 13:37 ` [PATCH v4 2/2] virtio_balloon: Use a workqueue instead of "vballoon" kthread Petr Mladek
2016-01-01 10:18 ` Michael S. Tsirkin
2016-01-02 11:43 ` Tejun Heo
2016-01-02 21:36 ` Michael S. Tsirkin
2016-01-03 13:58 ` Tejun Heo
2016-01-05 14:49 ` Petr Mladek
2016-01-05 15:37 ` Michael S. Tsirkin
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=20160101121124-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=jepler@unpythonic.net \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rusty@rustcorp.com.au \
--cc=tj@kernel.org \
--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).