[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <F2CBF3009FA73547804AE4C663CAB28E041A720C@shsmsx102.ccr.corp.intel.com>
Date: Wed, 25 May 2016 14:29:35 +0000
From: "Li, Liang Z" <liang.z.li@...el.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"qemu-devel@...gnu.org" <qemu-devel@...gnu.org>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"dgilbert@...hat.com" <dgilbert@...hat.com>,
"amit.shah@...hat.com" <amit.shah@...hat.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>
Subject: RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process
> > > Interesting. How about instead of tell host, we do multiple scans,
> > > each time ignoring pages out of range?
> > >
> > > for (pfn = min pfn; pfn < max pfn; pfn += 1G) {
> > > foreach page
> > > if page pfn < pfn || page pfn >= pfn + 1G
> > > continue
> > > set bit
> > > tell host
> > > }
> > >
> >
> > That means we have to allocate/free all the requested pages first, and then
> tell the host.
> > It works fine for inflating, but for deflating, because the page has
> > been deleted from the vb-> vb_dev_info->pages, so, we have to use a
> > struct to save the dequeued pages before calling
> > release_pages_balloon(),
>
> struct list_head? I think you can just replace set_page_pfns with
> list_add(&page->lru, &page_list);
>
>
That's is fine, I will retry and get back to you.
Thanks!
Liang
>
> > I think a page bitmap is the best struct to save these pages, because it
> consumes less memory.
> > And that bitmap should be large enough to save pfn 0 to max_pfn.
> >
> > If the above is true, then we are back to the square one. we really need a
> large page bitmap. Right?
> >
> > Liang
>
> These look like implementation issues to me.
>
> I think the below might be helpful (completely untested), your work can go
> on top.
>
> --->
>
> virtio-balloon: rework deflate to add page to a tmp list
>
> Will allow faster notifications using a bitmap down the road.
>
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
>
> ---
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 476c0e3..44050a3 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -195,8 +195,9 @@ static void release_pages_balloon(struct
> virtio_balloon *vb) static unsigned leak_balloon(struct virtio_balloon *vb,
> size_t num) {
> unsigned num_freed_pages;
> - struct page *page;
> + struct page *page, *next;
> struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
> + LIST_HEAD(pages); /* Pages dequeued for handing to
> Host */
>
> /* We can only do one array worth at a time. */
> num = min(num, ARRAY_SIZE(vb->pfns));
> @@ -207,10 +208,13 @@ static unsigned leak_balloon(struct virtio_balloon
> *vb, size_t num)
> page = balloon_page_dequeue(vb_dev_info);
> if (!page)
> break;
> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
> + list_add(&page->lru, &pages);
> vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
> }
>
> + list_for_each_entry_safe(page, next, &pages, lru)
> + set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
> +
> num_freed_pages = vb->num_pfns;
> /*
> * Note that if
> --
> MST
Powered by blists - more mailing lists