From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v6 kernel 3/5] virtio-balloon: speed up inflate/deflate process Date: Wed, 18 Jan 2017 17:30:12 +0200 Message-ID: <20170118172401-mutt-send-email-mst@kernel.org> References: <1482303148-22059-1-git-send-email-liang.z.li@intel.com> <1482303148-22059-4-git-send-email-liang.z.li@intel.com> <20170117211131-mutt-send-email-mst@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: "Li, Liang Z" Cc: "aarcange@redhat.com" , "virtio-dev@lists.oasis-open.org" , "kvm@vger.kernel.org" , "Hansen, Dave" , "qemu-devel@nongnu.org" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-mm@kvack.org" , "amit.shah@redhat.com" , "pbonzini@redhat.com" , "dgilbert@redhat.com" List-Id: virtualization@lists.linuxfoundation.org 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