[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v20210616 16/36] tools: save: move rec_pfns array


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Wed, 16 Jun 2021 14:51:09 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623847901; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=YoJCymJybJhr3GQavdsstKKb1/Nvxc490XeqP35kyEU=; b=IIuwyi298hRmgHzgfUA0RTSK18HEz9PFjl49wvz4GNtijls/hM1T1lViA5ZZ4FomUo dwzf6yJII2jbYgU0OH9x/aOuMv8vCzJBXg3V3I4ErpUNHuNU3Kg/37kSVusFe1UMCqPn i/Ucnfv1foekWiHBx7o7H/QkYtGRcabBfS37/dp/XxcmwON/xZG2qzpELliypDrye3MO SJtgtUYlGbJ3/0w5/1PSMZPQDGemGYO95P+gZTRBlWASmwk7hqqYDl6VZqHpkd0L2Y6Q O1DTTCFb1YCzR8dYzNdyW9p8M/TfTWux7d86Of8/EKkmXJGXA1SJntMrL8wgsctgMiLi +xTw==
  • Arc-seal: i=1; a=rsa-sha256; t=1623847901; cv=none; d=strato.com; s=strato-dkim-0002; b=Y7kTzV20Ryphv7nsbuvcPoIymod2LecV5RXqfm85m6o0JAABVhouZMriYYidwcN8EW 5OgB6B1FrI8ofK6nne/kDnK5IH+Aw2rD5N+mDtWs+5IIiX81F1XfRbjqYc06Z1PpN7C0 7nr5hAgrKpq2/ffaI3pu7uaOkLdDDFKmLQRkthc9fL+H6mT/PEnOGtnaLBiy5rFNvyqC OwQp4gdqSQpQLrdNbgMI9ba0Go1qx41r7lD7DamchIukCS2rJCo4RAAnf37ZCJ8dqM3h 079Se9Qjr3dB0kkYSAK2NlKjmYhXCSXKQ+NUCXQ1Dc7FiFmxFFA3tReN/O1YYgNQgxFs twew==
  • Authentication-results: strato.com; dkim=none
  • Cc: Olaf Hering <olaf@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 16 Jun 2021 13:08:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Remove allocation from hotpath, move rec_pfns array into preallocated space.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/libs/saverestore/common.h |  2 ++
 tools/libs/saverestore/save.c   | 11 +----------
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index ae87954364..2950947f1d 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -233,6 +233,8 @@ struct sr_save_arrays {
     int errors[MAX_BATCH_SIZE];
     /* write_batch: iovec[] for writev(). */
     struct iovec iov[MAX_BATCH_SIZE + 4];
+    /* write_batch */
+    uint64_t rec_pfns[MAX_BATCH_SIZE];
 };
 
 struct sr_restore_arrays {
diff --git a/tools/libs/saverestore/save.c b/tools/libs/saverestore/save.c
index 1a5f3d29ea..0f02988ff9 100644
--- a/tools/libs/saverestore/save.c
+++ b/tools/libs/saverestore/save.c
@@ -96,7 +96,7 @@ static int write_batch(struct xc_sr_context *ctx)
     unsigned int i, p, nr_pages = 0, nr_pages_mapped = 0;
     unsigned int nr_pfns = ctx->save.nr_batch_pfns;
     void *page, *orig_page;
-    uint64_t *rec_pfns = NULL;
+    uint64_t *rec_pfns = ctx->save.m->rec_pfns;
     struct iovec *iov = ctx->save.m->iov; int iovcnt = 0;
     struct xc_sr_rec_page_data_header hdr = { 0 };
     struct xc_sr_record rec = {
@@ -201,14 +201,6 @@ static int write_batch(struct xc_sr_context *ctx)
         }
     }
 
-    rec_pfns = malloc(nr_pfns * sizeof(*rec_pfns));
-    if ( !rec_pfns )
-    {
-        ERROR("Unable to allocate %zu bytes of memory for page data pfn list",
-              nr_pfns * sizeof(*rec_pfns));
-        goto err;
-    }
-
     hdr.count = nr_pfns;
 
     rec.length = sizeof(hdr);
@@ -259,7 +251,6 @@ static int write_batch(struct xc_sr_context *ctx)
     rc = ctx->save.nr_batch_pfns = 0;
 
  err:
-    free(rec_pfns);
     if ( guest_mapping )
         xenforeignmemory_unmap(xch->fmem, guest_mapping, nr_pages_mapped);
     for ( i = 0; local_pages && i < nr_pfns; ++i )



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.