Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1406214

RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process

From "Li, Liang Z" <liang.z.li@intel.com>
Newsgroups linux.kernel
Subject RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process
Date 2016-05-24 16:40 +0200
Message-ID <rClF0-4qa-13@gated-at.bofh.it> (permalink)
References (1 earlier) <rARpE-5ki-7@gated-at.bofh.it> <rChi1-1AN-5@gated-at.bofh.it> <rChrI-1Tg-11@gated-at.bofh.it> <rChUK-251-1@gated-at.bofh.it> <rCixs-2xY-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> > > > > 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 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
> > > > entire page bitmap, This RFC patch has already considered about this.
> > >
> > > where's that addressed in code?
> > >
> >
> > By record the start_pfn and end_pfn.
> >
> > The start_pfn & end_pfn will be updated in set_page_bitmap() and will
> > be used in the function tell_host():
> >
> > ----------------------------------------------------------------------
> > -----------
> > +static void set_page_bitmap(struct virtio_balloon *vb, struct page
> > +*page) {
> > +	unsigned int i;
> > +	unsigned long *bitmap = vb->page_bitmap;
> > +	unsigned long balloon_pfn = page_to_balloon_pfn(page);
> > +
> > +	for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++)
> > +		set_bit(balloon_pfn + i, bitmap);
> 
> BTW, there's a page size value in header so there is no longer need to set
> multiple bits per page.

Yes, you are right.

> 
> > +	if (balloon_pfn < vb->start_pfn)
> > +		vb->start_pfn = balloon_pfn;
> > +	if (balloon_pfn > vb->end_pfn)
> > +		vb->end_pfn = balloon_pfn;
> > +}
> 
> Sounds good, but you also need to limit by allocated bitmap size.

Why should we limit the page bitmap size? Is it no good to send a large page bitmap?
or to save the memory used for page bitmap? Or some other reason?
> 
> >
> > +		unsigned long start_pfn, end_pfn, flags = 0, bmap_len;
> > +		struct scatterlist sg[5];
> > +
> > +		start_pfn = rounddown(vb->start_pfn, BITS_PER_LONG);
> > +		end_pfn = roundup(vb->end_pfn, BITS_PER_LONG);
> > +		bmap_len = (end_pfn - start_pfn) / BITS_PER_LONG *
> sizeof(long);
> > +
> > +		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_buf(&sg[3], &bmap_len, sizeof(bmap_len));
> > +		sg_set_buf(&sg[4], vb->page_bitmap +
> > +				 (start_pfn / BITS_PER_LONG), bmap_len);
> 
> Looks wrong. start_pfn should start at offset 0 I think ...

I don't know what is wrong here, could you tell me why?

Thanks!

Liang

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC kernel] balloon: speed up inflating/deflating process Liang Li <liang.z.li@intel.com> - 2016-05-20 12:10 +0200
  Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process Paolo Bonzini <pbonzini@redhat.com> - 2016-05-20 13:30 +0200
    RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 10:00 +0200
  Re: [PATCH RFC kernel] balloon: speed up inflating/deflating  process Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-05-20 13:30 +0200
    RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 09:50 +0200
  Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-20 14:10 +0200
    RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 12:00 +0200
    RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 12:00 +0200
      Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-24 12:10 +0200
        RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 12:40 +0200
          Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-24 13:20 +0200
            RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-24 16:40 +0200
              Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-24 17:20 +0200
                RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 03:00 +0200
                RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 03:10 +0200
                Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-25 10:40 +0200
        RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 10:50 +0200
          Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-25 11:00 +0200
            RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 11:30 +0200
              Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-25 11:50 +0200
                RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 12:20 +0200
                Re: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Michael S. Tsirkin" <mst@redhat.com> - 2016-05-25 12:40 +0200
                RE: [PATCH RFC kernel] balloon: speed up inflating/deflating process "Li, Liang Z" <liang.z.li@intel.com> - 2016-05-25 16:40 +0200

csiph-web