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

[PATCH v20210601 18/38] tools/guest: restore: move pfns array


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 1 Jun 2021 18:10:58 +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=yMk7eA+P/3dbcIUts8vVxsnRdZMI0VGT4aHfrLA5Vm0=; b=pFtNbtmH4REr819pBxs6SzUv+AU/vAJ+tuUsrKPOlVkHmxuV7cwde7Lpc42PrRuqQF hIN/J18CK8/eQ5TyFS5VmoD/R8Si2F15MZJlH882EI+jHL2ZlpcSIYN8NjZwr65ra25l Hehz17AlrVFORkZC5fszCCMlOvgttk3SfMXbCjqBvUXO7tDpyx1iITXjXFqvqizxwJQt ZNSG9vuK3zmOWZ6Kgy6uPwD99y+8Wcsbp8V+2ea+MDTHjTkyHNtbGar3pyM4l1VfhEN/ f2dAV845M6Wwtd5k/knWona6J7AbiKmZl/djct1nIDlTYwLlKb4GSz9tS2Yr5Sy+3i9N sW6A==
  • Arc-seal: i=1; a=rsa-sha256; t=1622563893; cv=none; d=strato.com; s=strato-dkim-0002; b=NpnnLGqmKCVUQlrMkSAxwv++mpIPTiUMxYC7kJiZVaiJDEP3oT0dtrLAAfd6l4x6di yhfyFRysyH77HR5I0ndRZx0KCYWp97MSEzSl9OAfgCmU9NPbORVZjFWam4ePPSCdKhFx 1KMKXhhrwK7yKcCIhdpn+qLGk01i9XzX5ItSczWj9VgOXGCeJknJMnKcwXpj0mZBj0Dq nj14BTT61TUgHER1aApkp/8UiOo7fyxDmn6hT3gW9YiRSmAMWIqtbFSfTmul/OlvszJE iZuSRbNLn3SRQVOWTrfIVF4TgylKQonKfsc24dk/Hmgcn0wKqpWu5ervz5Btb6CFYzfL 4/qQ==
  • 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:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

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

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index 0e03b0731c..be6f98af7f 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -236,6 +236,8 @@ struct xc_sr_save_arrays {
 };
 
 struct xc_sr_restore_arrays {
+    /* handle_page_data */
+    xen_pfn_t pfns[MAX_BATCH_SIZE];
 };
 
 struct xc_sr_context
diff --git a/tools/libs/saverestore/restore.c b/tools/libs/saverestore/restore.c
index a6cf9ee41c..4d8ee19adf 100644
--- a/tools/libs/saverestore/restore.c
+++ b/tools/libs/saverestore/restore.c
@@ -315,7 +315,7 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
     unsigned int i, pages_of_data = 0;
     int rc = -1;
 
-    xen_pfn_t *pfns = NULL, pfn;
+    xen_pfn_t *pfns = ctx->restore.m->pfns, pfn;
     uint32_t *types = NULL, type;
 
     /*
@@ -363,9 +363,8 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
         goto err;
     }
 
-    pfns = malloc(pages->count * sizeof(*pfns));
     types = malloc(pages->count * sizeof(*types));
-    if ( !pfns || !types )
+    if ( !types )
     {
         ERROR("Unable to allocate enough memory for %u pfns",
               pages->count);
@@ -412,7 +411,6 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
                            &pages->pfn[pages->count]);
  err:
     free(types);
-    free(pfns);
 
     return rc;
 }



 


Rackspace

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