Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1560954 > unrolled thread
| Started by | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| First post | 2017-01-17 20:30 +0100 |
| Last post | 2017-01-20 17:40 +0100 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process "Michael S. Tsirkin" <mst@redhat.com> - 2017-01-17 20:30 +0100
RE: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process "Li, Liang Z" <liang.z.li@intel.com> - 2017-01-18 06:10 +0100
Re: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process "Michael S. Tsirkin" <mst@redhat.com> - 2017-01-18 16:40 +0100
RE: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process "Li, Liang Z" <liang.z.li@intel.com> - 2017-01-19 02:50 +0100
Re: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process "Michael S. Tsirkin" <mst@redhat.com> - 2017-01-20 17:40 +0100
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2017-01-17 20:30 +0100 |
| Subject | Re: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process |
| Message-ID | <t0HCa-2BA-29@gated-at.bofh.it> |
On Wed, Dec 21, 2016 at 02:52:26PM +0800, Liang Li wrote:
>
> - /* We should always be able to add one buffer to an empty queue. */
> - virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
> - virtqueue_kick(vq);
> +static void do_set_resp_bitmap(struct virtio_balloon *vb,
> + unsigned long base_pfn, int pages)
>
> - /* When host has read buffer, this completes via balloon_ack */
> - wait_event(vb->acked, virtqueue_get_buf(vq, &len));
> +{
> + __le64 *range = vb->resp_data + vb->resp_pos;
>
> + if (pages > (1 << VIRTIO_BALLOON_NR_PFN_BITS)) {
> + /* when the length field can't contain pages, set it to 0 to
/*
* Multi-line
* comments
* should look like this.
*/
Also, pls start sentences with an upper-case letter.
> + * indicate the actual length is in the next __le64;
> + */
This is part of the interface so should be documented as such.
> + *range = cpu_to_le64((base_pfn <<
> + VIRTIO_BALLOON_NR_PFN_BITS) | 0);
> + *(range + 1) = cpu_to_le64(pages);
> + vb->resp_pos += 2;
Pls use structs for this kind of stuff.
> + } else {
> + *range = (base_pfn << VIRTIO_BALLOON_NR_PFN_BITS) | pages;
> + vb->resp_pos++;
> + }
> +}
[toc] | [next] | [standalone]
| From | "Li, Liang Z" <liang.z.li@intel.com> |
|---|---|
| Date | 2017-01-18 06:10 +0100 |
| Message-ID | <t0QFr-8dY-1@gated-at.bofh.it> |
| In reply to | #1560954 |
> > - virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
> > - virtqueue_kick(vq);
> > +static void do_set_resp_bitmap(struct virtio_balloon *vb,
> > + unsigned long base_pfn, int pages)
> >
> > - /* When host has read buffer, this completes via balloon_ack */
> > - wait_event(vb->acked, virtqueue_get_buf(vq, &len));
> > +{
> > + __le64 *range = vb->resp_data + vb->resp_pos;
> >
> > + if (pages > (1 << VIRTIO_BALLOON_NR_PFN_BITS)) {
> > + /* when the length field can't contain pages, set it to 0 to
>
> /*
> * Multi-line
> * comments
> * should look like this.
> */
>
> Also, pls start sentences with an upper-case letter.
>
Sorry for that.
> > + * indicate the actual length is in the next __le64;
> > + */
>
> This is part of the interface so should be documented as such.
>
> > + *range = cpu_to_le64((base_pfn <<
> > + VIRTIO_BALLOON_NR_PFN_BITS) | 0);
> > + *(range + 1) = cpu_to_le64(pages);
> > + vb->resp_pos += 2;
>
> Pls use structs for this kind of stuff.
I am not sure if you mean to use
struct range {
__le64 pfn: 52;
__le64 nr_page: 12
}
Instead of the shift operation?
I didn't use this way because I don't want to include 'virtio-balloon.h' in page_alloc.c,
or copy the define of this struct in page_alloc.c
Thanks!
Liang
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2017-01-18 16:40 +0100 |
| Message-ID | <t10v7-5P4-19@gated-at.bofh.it> |
| In reply to | #1561272 |
On Wed, Jan 18, 2017 at 04:56:58AM +0000, Li, Liang Z wrote:
> > > - virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
> > > - virtqueue_kick(vq);
> > > +static void do_set_resp_bitmap(struct virtio_balloon *vb,
> > > + unsigned long base_pfn, int pages)
> > >
> > > - /* When host has read buffer, this completes via balloon_ack */
> > > - wait_event(vb->acked, virtqueue_get_buf(vq, &len));
> > > +{
> > > + __le64 *range = vb->resp_data + vb->resp_pos;
> > >
> > > + if (pages > (1 << VIRTIO_BALLOON_NR_PFN_BITS)) {
> > > + /* when the length field can't contain pages, set it to 0 to
> >
> > /*
> > * Multi-line
> > * comments
> > * should look like this.
> > */
> >
> > Also, pls start sentences with an upper-case letter.
> >
>
> Sorry for that.
>
> > > + * indicate the actual length is in the next __le64;
> > > + */
> >
> > This is part of the interface so should be documented as such.
> >
> > > + *range = cpu_to_le64((base_pfn <<
> > > + VIRTIO_BALLOON_NR_PFN_BITS) | 0);
> > > + *(range + 1) = cpu_to_le64(pages);
> > > + vb->resp_pos += 2;
> >
> > Pls use structs for this kind of stuff.
>
> I am not sure if you mean to use
>
> struct range {
> __le64 pfn: 52;
> __le64 nr_page: 12
> }
> Instead of the shift operation?
Not just that. You want to add a pages field as well.
Generally describe the format in the header in some way
so host and guest can easily stay in sync.
All the pointer math and void * means we get zero type
safety and I'm not happy about it.
> I didn't use this way because I don't want to include 'virtio-balloon.h' in page_alloc.c,
> or copy the define of this struct in page_alloc.c
>
> Thanks!
> Liang
It's not good that virtio format seeps out to page_alloc anyway.
If unavoidable it is not a good idea to try to hide this fact,
people will assume they can change the format at will.
--
MST
[toc] | [prev] | [next] | [standalone]
| From | "Li, Liang Z" <liang.z.li@intel.com> |
|---|---|
| Date | 2017-01-19 02:50 +0100 |
| Message-ID | <t1a1s-3mo-19@gated-at.bofh.it> |
| In reply to | #1561901 |
> On Wed, Jan 18, 2017 at 04:56:58AM +0000, Li, Liang Z wrote:
> > > > - virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
> > > > - virtqueue_kick(vq);
> > > > +static void do_set_resp_bitmap(struct virtio_balloon *vb,
> > > > + unsigned long base_pfn, int pages)
> > > >
> > > > - /* When host has read buffer, this completes via balloon_ack */
> > > > - wait_event(vb->acked, virtqueue_get_buf(vq, &len));
> > > > +{
> > > > + __le64 *range = vb->resp_data + vb->resp_pos;
> > > >
> > > > + if (pages > (1 << VIRTIO_BALLOON_NR_PFN_BITS)) {
> > > > + /* when the length field can't contain pages, set it to 0 to
> > >
> > > /*
> > > * Multi-line
> > > * comments
> > > * should look like this.
> > > */
> > >
> > > Also, pls start sentences with an upper-case letter.
> > >
> >
> > Sorry for that.
> >
> > > > + * indicate the actual length is in the next __le64;
> > > > + */
> > >
> > > This is part of the interface so should be documented as such.
> > >
> > > > + *range = cpu_to_le64((base_pfn <<
> > > > + VIRTIO_BALLOON_NR_PFN_BITS) | 0);
> > > > + *(range + 1) = cpu_to_le64(pages);
> > > > + vb->resp_pos += 2;
> > >
> > > Pls use structs for this kind of stuff.
> >
> > I am not sure if you mean to use
> >
> > struct range {
> > __le64 pfn: 52;
> > __le64 nr_page: 12
> > }
> > Instead of the shift operation?
>
> Not just that. You want to add a pages field as well.
>
pages field? Could you give more hints?
> Generally describe the format in the header in some way so host and guest
> can easily stay in sync.
'VIRTIO_BALLOON_NR_PFN_BITS' is for this purpose and it will be passed to the
related function in page_alloc.c as a parameter.
Thanks!
Liang
> All the pointer math and void * means we get zero type safety and I'm not
> happy about it.
>
> It's not good that virtio format seeps out to page_alloc anyway.
> If unavoidable it is not a good idea to try to hide this fact, people will assume
> they can change the format at will.
>
> --
> MST
[toc] | [prev] | [next] | [standalone]
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2017-01-20 17:40 +0100 |
| Message-ID | <t1Koh-19S-13@gated-at.bofh.it> |
| In reply to | #1562372 |
On Thu, Jan 19, 2017 at 01:44:36AM +0000, Li, Liang Z wrote:
> > > > > + *range = cpu_to_le64((base_pfn <<
> > > > > + VIRTIO_BALLOON_NR_PFN_BITS) | 0);
> > > > > + *(range + 1) = cpu_to_le64(pages);
> > > > > + vb->resp_pos += 2;
> > > >
> > > > Pls use structs for this kind of stuff.
> > >
> > > I am not sure if you mean to use
> > >
> > > struct range {
> > > __le64 pfn: 52;
> > > __le64 nr_page: 12
> > > }
> > > Instead of the shift operation?
> >
> > Not just that. You want to add a pages field as well.
> >
>
> pages field? Could you give more hints?
Well look how you are formatting it manually above.
There is clearly a structure with two 64 bit fields.
First one includes pfn and 0 (no idea why does | 0 make
sense but that's a separate issue).
Second one includes the pages value.
> > Generally describe the format in the header in some way so host and guest
> > can easily stay in sync.
>
> 'VIRTIO_BALLOON_NR_PFN_BITS' is for this purpose and it will be passed to the
> related function in page_alloc.c as a parameter.
>
> Thanks!
> Liang
> > All the pointer math and void * means we get zero type safety and I'm not
> > happy about it.
> >
> > It's not good that virtio format seeps out to page_alloc anyway.
> > If unavoidable it is not a good idea to try to hide this fact, people will assume
> > they can change the format at will.
> >
> > --
> > MST
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web