[Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-20 Thread Liang Li
The implementation of the current virtio-balloon is not very efficient, Bellow is test result of time spends on inflating the balloon to 3GB of a 4GB idle guest: a. allocating pages (6.5%, 103ms) b. sending PFNs to host (68.3%, 787ms) c. address translation (6.1%, 96ms) d. madvise (19%, 300ms) It

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-20 Thread Paolo Bonzini
On 20/05/2016 11:59, Liang Li wrote: > + > + sg_init_table(sg, 5); > + sg_set_buf(&sg[0], &flags, sizeof(flags)); > + sg_set_buf(&sg[1], &start_pfn, sizeof(start_pfn)); > + sg_set_buf(&sg[2], &page_shift, sizeof(page_shift)); > + sg_set_

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-20 Thread Cornelia Huck
On Fri, 20 May 2016 17:59:46 +0800 Liang Li wrote: > The implementation of the current virtio-balloon is not very efficient, > Bellow is test result of time spends on inflating the balloon to 3GB of > a 4GB idle guest: > > a. allocating pages (6.5%, 103ms) > b. sending PFNs to host (68.3%, 787ms

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-20 Thread Michael S. Tsirkin
On Fri, May 20, 2016 at 05:59:46PM +0800, Liang Li wrote: > The implementation of the current virtio-balloon is not very efficient, > Bellow is test result of time spends on inflating the balloon to 3GB of > a 4GB idle guest: > > a. allocating pages (6.5%, 103ms) > b. sending PFNs to host (68.3%,

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> On Fri, 20 May 2016 17:59:46 +0800 > Liang Li wrote: > > > The implementation of the current virtio-balloon is not very > > efficient, Bellow is test result of time spends on inflating the > > balloon to 3GB of a 4GB idle guest: > > > > a. allocating pages (6.5%, 103ms) > > b. sending PFNs to h

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> On 20/05/2016 11:59, Liang Li wrote: > > + > > + sg_init_table(sg, 5); > > + sg_set_buf(&sg[0], &flags, sizeof(flags)); > > + sg_set_buf(&sg[1], &start_pfn, sizeof(start_pfn)); > > + sg_set_buf(&sg[2], &page_shift, sizeof(page_shift)); > > + sg_se

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> On Fri, May 20, 2016 at 05:59:46PM +0800, Liang Li wrote: > > The implementation of the current virtio-balloon is not very > > efficient, Bellow is test result of time spends on inflating the > > balloon to 3GB of a 4GB idle guest: > > > > a. allocating pages (6.5%, 103ms) > > b. sending PFNs to

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> > On Fri, May 20, 2016 at 05:59:46PM +0800, Liang Li wrote: > > > The implementation of the current virtio-balloon is not very > > > efficient, Bellow is test result of time spends on inflating the > > > balloon to 3GB of a 4GB idle guest: > > > > > > a. allocating pages (6.5%, 103ms) > > > b. se

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Michael S. Tsirkin
On Tue, May 24, 2016 at 09:51:46AM +, Li, Liang Z wrote: > > On Fri, May 20, 2016 at 05:59:46PM +0800, Liang Li wrote: > > > The implementation of the current virtio-balloon is not very > > > efficient, Bellow is test result of time spends on inflating the > > > balloon to 3GB of a 4GB idle gue

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> > > > { > > > > - struct scatterlist sg; > > > > unsigned int len; > > > > > > > > - sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); > > > > + if (virtio_has_feature(vb->vdev, > > > VIRTIO_BALLOON_F_PAGE_BITMAP)) { > > > > + u32 page_shift

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Michael S. Tsirkin
On Tue, May 24, 2016 at 10:38:43AM +, Li, Liang Z wrote: > > > > > { > > > > > - struct scatterlist sg; > > > > > unsigned int len; > > > > > > > > > > - sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); > > > > > + if (virtio_has_feature(vb->vdev, > > > > VIRTI

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> > > > > This can be pre-initialized, correct? > > > > > > > > pre-initialized? I am not quite understand your mean. > > > > > > I think you can maintain sg as part of device state and init sg with the > bitmap. > > > > > > > I got it. > > > > > > > This is grossly inefficient if you only requeste

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Michael S. Tsirkin
On Tue, May 24, 2016 at 02:36:08PM +, Li, Liang Z wrote: > > > > > > This can be pre-initialized, correct? > > > > > > > > > > pre-initialized? I am not quite understand your mean. > > > > > > > > I think you can maintain sg as part of device state and init sg with the > > bitmap. > > > > > > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> On Tue, May 24, 2016 at 02:36:08PM +, Li, Liang Z wrote: > > > > > > > This can be pre-initialized, correct? > > > > > > > > > > > > pre-initialized? I am not quite understand your mean. > > > > > > > > > > I think you can maintain sg as part of device state and init sg > > > > > with the > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-24 Thread Li, Liang Z
> > > > > > > This is grossly inefficient if you only requested a single page. > > > > > > > And it's also allocating memory very aggressively without > > > > > > > ever telling the host what is going on. > > > > > > > > > > > > If only requested a single page, there is no need to send the > > > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Michael S. Tsirkin
On Wed, May 25, 2016 at 01:00:27AM +, Li, Liang Z wrote: > It should be changed if we are going to use a small page bitmap. Exactly.

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Li, Liang Z
> > > Suggestion to address all above comments: > > > 1. allocate a bunch of pages and link them up, > > > calculating the min and the max pfn. > > > if max-min exceeds the allocated bitmap size, > > > tell host. > > > > I am not sure if it works well in some cases, e.g. The alloca

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Michael S. Tsirkin
On Wed, May 25, 2016 at 08:48:17AM +, Li, Liang Z wrote: > > > > Suggestion to address all above comments: > > > > 1. allocate a bunch of pages and link them up, > > > >calculating the min and the max pfn. > > > >if max-min exceeds the allocated bitmap size, > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Li, Liang Z
> On Wed, May 25, 2016 at 08:48:17AM +, Li, Liang Z wrote: > > > > > Suggestion to address all above comments: > > > > > 1. allocate a bunch of pages and link them up, > > > > > calculating the min and the max pfn. > > > > > if max-min exceeds the allocated bitmap size,

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Michael S. Tsirkin
On Wed, May 25, 2016 at 09:28:58AM +, Li, Liang Z wrote: > > On Wed, May 25, 2016 at 08:48:17AM +, Li, Liang Z wrote: > > > > > > Suggestion to address all above comments: > > > > > > 1. allocate a bunch of pages and link them up, > > > > > >calculating the min and the max pfn.

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Li, Liang Z
> > > > > > > > Hi MST, > > > > > > > > I have measured the performance when using a 32K page bitmap, > > > > > > Just to make sure. Do you mean a 32Kbyte bitmap? > > > Covering 1Gbyte of memory? > > Yes. > > > > > > > > > and inflate the balloon to 3GB > > > > of an idle guest with 4GB RAM. > > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Michael S. Tsirkin
On Wed, May 25, 2016 at 10:10:47AM +, Li, Liang Z wrote: > > > > > > > > > > Hi MST, > > > > > > > > > > I have measured the performance when using a 32K page bitmap, > > > > > > > > Just to make sure. Do you mean a 32Kbyte bitmap? > > > > Covering 1Gbyte of memory? > > > Yes. > > > > > > > > >

Re: [Qemu-devel] [PATCH RFC kernel] balloon: speed up inflating/deflating process

2016-05-25 Thread Li, Liang Z
> > > 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 > > >