From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIiM6-0003BS-It for qemu-devel@nongnu.org; Thu, 21 Mar 2013 12:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIiM0-0006Xv-7Y for qemu-devel@nongnu.org; Thu, 21 Mar 2013 12:28:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIiLz-0006Xl-US for qemu-devel@nongnu.org; Thu, 21 Mar 2013 12:28:36 -0400 Date: Thu, 21 Mar 2013 18:29:12 +0200 From: "Michael S. Tsirkin" Message-ID: <20130321162912.GH1925@redhat.com> References: <1363881940-27505-1-git-send-email-owasserm@redhat.com> <1363881940-27505-10-git-send-email-owasserm@redhat.com> <20130321161608.GE1925@redhat.com> <514B34FE.6010901@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <514B34FE.6010901@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Orit Wasserman Cc: pbonzini@redhat.com, chegu_vinod@hp.com, qemu-devel@nongnu.org, quintela@redhat.com On Thu, Mar 21, 2013 at 06:27:42PM +0200, Orit Wasserman wrote: > On 03/21/2013 06:16 PM, Michael S. Tsirkin wrote: > > On Thu, Mar 21, 2013 at 06:05:40PM +0200, Orit Wasserman wrote: > >> This way we send one big buffer instead of many small ones > >> > >> Signed-off-by: Orit Wasserman > > > > Why does this happen BTW? > > It happens in the last phase when we send the device state that consists of a lot > bytes and int field that are written using qemu_put_byte/be16/... > Confused I thought device_state does not use _nocopy? My idea of using vmsplice relies exactly on this: we can not splice device state ... > > > >> --- > >> savevm.c | 21 +++++++++++++++++---- > >> 1 file changed, 17 insertions(+), 4 deletions(-) > >> > >> diff --git a/savevm.c b/savevm.c > >> index 50e8fb2..13a533b 100644 > >> --- a/savevm.c > >> +++ b/savevm.c > >> @@ -634,8 +634,14 @@ void qemu_put_buffer_no_copy(QEMUFile *f, const uint8_t *buf, int size) > >> abort(); > >> } > >> > >> - f->iov[f->iovcnt].iov_base = (uint8_t *)buf; > >> - f->iov[f->iovcnt++].iov_len = size; > >> + /* check for adjoint buffer and colace them */ > >> + if (f->iovcnt > 0 && buf == f->iov[f->iovcnt - 1].iov_base + > >> + f->iov[f->iovcnt - 1].iov_len) { > >> + f->iov[f->iovcnt - 1].iov_len += size; > >> + } else { > >> + f->iov[f->iovcnt].iov_base = (uint8_t *)buf; > >> + f->iov[f->iovcnt++].iov_len = size; > >> + } > >> > >> f->is_write = 1; > >> f->bytes_xfer += size; > >> @@ -690,8 +696,15 @@ void qemu_put_byte(QEMUFile *f, int v) > >> f->buf[f->buf_index++] = v; > >> f->is_write = 1; > >> f->bytes_xfer += 1; > >> - f->iov[f->iovcnt].iov_base = f->buf + (f->buf_index - 1); > >> - f->iov[f->iovcnt++].iov_len = 1; > >> + > >> + /* check for adjoint buffer and colace them */ > >> + if (f->iovcnt > 0 && f->buf + (f->buf_index - 1) == > >> + f->iov[f->iovcnt - 1].iov_base + f->iov[f->iovcnt - 1].iov_len) { > >> + f->iov[f->iovcnt - 1].iov_len += 1; > >> + } else { > >> + f->iov[f->iovcnt].iov_base = f->buf + (f->buf_index - 1); > >> + f->iov[f->iovcnt++].iov_len = 1; > >> + } > >> > >> if (f->buf_index >= IO_BUF_SIZE || f->iovcnt >= MAX_IOV_SIZE) { > >> qemu_fflush(f); > >> -- > >> 1.7.11.7