[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs
From: |
Orit Wasserman |
Subject: |
[Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs |
Date: |
Thu, 21 Mar 2013 18:05:40 +0200 |
This way we send one big buffer instead of many small ones
Signed-off-by: Orit Wasserman <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH v3 3/9] Update bytes_xfer in qemu_put_byte, (continued)
- [Qemu-devel] [PATCH v3 4/9] Store the data to send also in iovec, Orit Wasserman, 2013/03/21
- [Qemu-devel] [PATCH v3 5/9] Use writev ops if available, Orit Wasserman, 2013/03/21
- [Qemu-devel] [PATCH v3 6/9] More optimized qemu_put_be64/32/16, Orit Wasserman, 2013/03/21
- [Qemu-devel] [PATCH v3 7/9] Add qemu_put_buffer_no_copy, Orit Wasserman, 2013/03/21
- [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs,
Orit Wasserman <=
- Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Michael S. Tsirkin, 2013/03/21
- Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Juan Quintela, 2013/03/21
- Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Michael S. Tsirkin, 2013/03/21
- Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Juan Quintela, 2013/03/21
- Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Michael S. Tsirkin, 2013/03/21
Re: [Qemu-devel] [PATCH v3 9/9] coalesce adjacent iovecs, Juan Quintela, 2013/03/21