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

[PATCH v20210616 23/36] tools: restore: move pfns array in populate_pfns


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Wed, 16 Jun 2021 14:51:16 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623847904; 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=pnLF16VUG8E4Jp5fWe4D439r7jQrrghaZKOdiE+JFI0=; b=t1ElC85hwloXfK5N6nrxainkrTPKhRZHdvPq6dL7JDtPKhDFDmDwz3Jdbpi33IVN+B ZHt7hvT3IcBtT/zhhe7WP2SuBbMhqEkYjShsDFuy8JzXQymbXn5pP14l+PMIOu5Mk8IE L2s4nWXoAO+1H3V/NwRbw3zUSOozMY2Xso2gyVL32e2MECs7C4UG0nRY+j16xh9RYsqD FBhieSIpl/MZciH0KcH3f+lGdZos3fpLTm8jCl4ZGR0ou2t84iSShLXhEjuPhMB+o/Zp 2luAbl6KpFxhKQszOy/tZXz4JDtMJXI1HFNEfGOaxS2O1/bf1FPK5g1SEZuI8nkmIAmo 9OxA==
  • Arc-seal: i=1; a=rsa-sha256; t=1623847904; cv=none; d=strato.com; s=strato-dkim-0002; b=LTxVl9Oyg2idIwCSzLv4XMhSMg50poqnIqEXBORyknOrl2MMSI8beM3alR1r8dAiNq qQfKyOwHUDeig5sb4IxCh8JoJYfeG+8N8odQsng/yKsGvQqpo2ptViKYqtC/Xzo5G5nJ 5rPBsCgXIsNDynCFvKqv9xIX/YbMCyuBZAXUeAXhABJPZ52VZOqtKnJLYd26Xzagk5rp GrkRAX8yk5p+ZOQr4/fqYvZmh3EJrfoEquOCGKFDnhps7jrTi+SHpFY/Mr9UDejr2Phi FMgXxfgo4wGBjdWZchBjwZ5wM1pbXDU/YG5JUvfGHbswerXw5v8Y7MkfGRcuvGFgxfNM lVvQ==
  • 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 12:52:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Remove allocation from hotpath, move populate_pfns' pfns array into 
preallocated space.
Use some prefix to avoid conflict with an array used in handle_page_data.

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

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index 3cfb23861f..379887e149 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -244,6 +244,7 @@ struct sr_restore_arrays {
     int map_errs[MAX_BATCH_SIZE];
     /* populate_pfns */
     xen_pfn_t pp_mfns[MAX_BATCH_SIZE];
+    xen_pfn_t pp_pfns[MAX_BATCH_SIZE];
 };
 
 struct xc_sr_context
diff --git a/tools/libs/saverestore/restore.c b/tools/libs/saverestore/restore.c
index 0c29478ccb..f2234eac55 100644
--- a/tools/libs/saverestore/restore.c
+++ b/tools/libs/saverestore/restore.c
@@ -139,17 +139,10 @@ int populate_pfns(struct xc_sr_context *ctx, unsigned int 
count,
 {
     xc_interface *xch = ctx->xch;
     xen_pfn_t *mfns = ctx->restore.m->pp_mfns,
-        *pfns = malloc(count * sizeof(*pfns));
+        *pfns = ctx->restore.m->pp_pfns;
     unsigned int i, nr_pfns = 0;
     int rc = -1;
 
-    if ( !pfns )
-    {
-        ERROR("Failed to allocate %zu bytes for populating the physmap",
-              2 * count * sizeof(*mfns));
-        goto err;
-    }
-
     for ( i = 0; i < count; ++i )
     {
         if ( (!types ||
@@ -190,8 +183,6 @@ int populate_pfns(struct xc_sr_context *ctx, unsigned int 
count,
     rc = 0;
 
  err:
-    free(pfns);
-
     return rc;
 }
 



 


Rackspace

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