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

[PATCH v20210601 19/38] tools/guest: restore: move types array


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 1 Jun 2021 18:10:59 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622563893; 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=aAGkFwdPcwm3sDiRcDYWvmNyL5GfWbZILOcBD1kChMw=; b=WuaAIM3CKjPaQpNFLkan3sxYrsUWe15VJwwOkRkJvJxFSNzjJkgTaoyqLco1NVrvik rDuEQMjXNbIACUimJfcEG69pNeM6uCtuaQ8Z0EcPFjrWRWCSrNinT7dG9UYinAeNWf+T BRt2KbTc/kkZkoBrjm3c1HZ47YFOhYDghdpchGOrTTPl9UGjY570bg0DwOTkK3qwuaoG SRr2SfNQAWE/7zZD93V39TnKrzPtr5CXXmJuGhizFzZSHqfgaBwO2qLfL2qHvVJGM4VY 6E4qdAfjNY0gfHLFNI//uKFaw6X7WqJD6xWS1UjiDHqpzbst0LQKkDn1mIYkH6rGCAro Ysew==
  • Arc-seal: i=1; a=rsa-sha256; t=1622563893; cv=none; d=strato.com; s=strato-dkim-0002; b=UUM+exyc4Jrd1VjUci/3jYH7JekthyphWT5aBWkhbqXHdikeRhjJciVwYbT6pBKxnQ sCssb14D+0d2l0ieo61vaGv/+gXHHH0EIgc9VlWAxVVaC2JVUuXpooY0PbGOdAlWumq8 RLyO6YzqPa4LgKySXRHvrReFKUokuRTDFPvPRMuV0dVCc9atUNRe3fKHl+WpkYSPVpYb /bXBKI80r82XVNiBFSE9nsa4s3yxbkV5mbnu3D+UmHk4ZYQzsXJdDNYGA6eEmDhRPI4o mohDQD0ZKRxBBq4hWYx24LWbRepKO9i7xRbsPrVxSLnYrDDtpmfVOg4hoSSvmpXU4foG vtcg==
  • Authentication-results: strato.com; dkim=none
  • Cc: Olaf Hering <olaf@xxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 01 Jun 2021 16:13:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
 tools/libs/saverestore/common.h  |  1 +
 tools/libs/saverestore/restore.c | 12 +-----------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index be6f98af7f..96cd60e0d6 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -238,6 +238,7 @@ struct xc_sr_save_arrays {
 struct xc_sr_restore_arrays {
     /* handle_page_data */
     xen_pfn_t pfns[MAX_BATCH_SIZE];
+    uint32_t types[MAX_BATCH_SIZE];
 };
 
 struct xc_sr_context
diff --git a/tools/libs/saverestore/restore.c b/tools/libs/saverestore/restore.c
index 4d8ee19adf..815a2d5a12 100644
--- a/tools/libs/saverestore/restore.c
+++ b/tools/libs/saverestore/restore.c
@@ -316,7 +316,7 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
     int rc = -1;
 
     xen_pfn_t *pfns = ctx->restore.m->pfns, pfn;
-    uint32_t *types = NULL, type;
+    uint32_t *types = ctx->restore.m->types, type;
 
     /*
      * v2 compatibility only exists for x86 streams.  This is a bit of a
@@ -363,14 +363,6 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
         goto err;
     }
 
-    types = malloc(pages->count * sizeof(*types));
-    if ( !types )
-    {
-        ERROR("Unable to allocate enough memory for %u pfns",
-              pages->count);
-        goto err;
-    }
-
     for ( i = 0; i < pages->count; ++i )
     {
         pfn = pages->pfn[i] & PAGE_DATA_PFN_MASK;
@@ -410,8 +402,6 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
     rc = process_page_data(ctx, pages->count, pfns, types,
                            &pages->pfn[pages->count]);
  err:
-    free(types);
-
     return rc;
 }
 



 


Rackspace

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