|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/4] xenguest: Reduce number of I/O vectors in write_batch
From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
Small optimization.
Reduce number of pieces passed to writev.
Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
---
tools/libs/guest/xg_sr_save.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c
index 3b2c5222e4..1700d81905 100644
--- a/tools/libs/guest/xg_sr_save.c
+++ b/tools/libs/guest/xg_sr_save.c
@@ -97,9 +97,12 @@ static int write_batch(struct xc_sr_context *ctx)
void *page, *orig_page;
uint64_t *rec_pfns = NULL;
struct iovec *iov = NULL; int iovcnt = 0;
- struct xc_sr_rec_page_data_header hdr = { 0 };
- struct xc_sr_record rec = {
- .type = REC_TYPE_PAGE_DATA,
+ struct {
+ struct xc_sr_rhdr rec;
+ struct xc_sr_rec_page_data_header page_data;
+ } hdrs = {
+ { .type = REC_TYPE_PAGE_DATA },
+ { 0 },
};
assert(nr_pfns != 0);
@@ -115,7 +118,7 @@ static int write_batch(struct xc_sr_context *ctx)
/* Pointers to locally allocated pages. Need freeing. */
local_pages = calloc(nr_pfns, sizeof(*local_pages));
/* iovec[] for writev(). */
- iov = malloc((nr_pfns + 4) * sizeof(*iov));
+ iov = malloc((nr_pfns + 2) * sizeof(*iov));
if ( !mfns || !types || !errors || !guest_data || !local_pages || !iov )
{
@@ -216,28 +219,22 @@ static int write_batch(struct xc_sr_context *ctx)
goto err;
}
- hdr.count = nr_pfns;
+ hdrs.rec.length = sizeof(hdrs.page_data);
+ hdrs.rec.length += nr_pfns * sizeof(*rec_pfns);
+ hdrs.rec.length += nr_pages * PAGE_SIZE;
- rec.length = sizeof(hdr);
- rec.length += nr_pfns * sizeof(*rec_pfns);
- rec.length += nr_pages * PAGE_SIZE;
+ hdrs.page_data.count = nr_pfns;
for ( i = 0; i < nr_pfns; ++i )
rec_pfns[i] = ((uint64_t)(types[i]) << 32) | ctx->save.batch_pfns[i];
- iov[0].iov_base = &rec.type;
- iov[0].iov_len = sizeof(rec.type);
+ iov[0].iov_base = &hdrs;
+ iov[0].iov_len = sizeof(hdrs);
- iov[1].iov_base = &rec.length;
- iov[1].iov_len = sizeof(rec.length);
+ iov[1].iov_base = rec_pfns;
+ iov[1].iov_len = nr_pfns * sizeof(*rec_pfns);
- iov[2].iov_base = &hdr;
- iov[2].iov_len = sizeof(hdr);
-
- iov[3].iov_base = rec_pfns;
- iov[3].iov_len = nr_pfns * sizeof(*rec_pfns);
-
- iovcnt = 4;
+ iovcnt = 2;
if ( nr_pages )
{
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |