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

[PATCH v20210601 13/38] tools/guest: save: move errors array


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 1 Jun 2021 18:10:53 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622563891; 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=1Vlq702zoBkp5PCmpnAeHRVWBwGGiYV8RLsu7fpX0qA=; b=jbQ28FbpZshSCLQxBf2YVYZKWlfJQNtSvqQz9GWFU1unQnx11tq3ODYUqT26XjAAC6 +bIyj4IxL0vdH5I/W9uSsG6HIJq4GkqondTs5j12K8ressIjv1boHQ+UxhFXTILZXfNK 3BTnKDb6ntItpXfLrM4PSroAB4dAFWvs6GdlH/7Fvuy3evm+rEmRiD/Aa6UPuPeiYsT9 GvAS/z6VBJzfTkulBz7doXRyhFKtzx4xoJCUGEBrSh4SBPOm15x5VHo4EcMHtHCh9+x+ r0ZBkT8SotrGgADOvN7BzyYUX7MGRquG4xVNvimOOaeF3v3oQNr6Vy/SBuqJU0Bkf3AP 6tJw==
  • Arc-seal: i=1; a=rsa-sha256; t=1622563891; cv=none; d=strato.com; s=strato-dkim-0002; b=LCJtyMR+Zgd7W9rxsbxtC58x5DfEqpSITeFdBdbnYt4fP5IZM6iO61a5JCg+irtKtN WF8XQtNF/OaWj6lSX7ugEy9guiW6JR4O94cMSSlJUQhDGZ3OP0PTpsPwEdMtZ8VmDI2r Ed9b3gCHYbq3hH1qAhtFLlPuPQVr5A1PrrG66MlKkrH87v3zgeEQOCtBt94mDb3e4jIa hbD+kZNaMF2Ix8BEhjmoe/JyS7jEXSYCrC1o0iWeAnjRp+KhxLidp8JX0PYOSMAgnG9c FyUNV4og2SgLVQj4v211CNDBBsD6N1GDIGABj/Tb3y+IPC5ukaMF4vUP1aKWJ1bKgAAY P6xg==
  • 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:12:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

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

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index 81d4a79b13..07dfa7d57d 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -229,6 +229,8 @@ struct xc_sr_save_arrays {
     xen_pfn_t mfns[MAX_BATCH_SIZE];
     /* write_batch: Types of the batch pfns. */
     xen_pfn_t types[MAX_BATCH_SIZE];
+    /* write_batch: Errors from attempting to map the gfns. */
+    int errors[MAX_BATCH_SIZE];
 };
 
 struct xc_sr_restore_arrays {
diff --git a/tools/libs/saverestore/save.c b/tools/libs/saverestore/save.c
index be65286570..5033f18bef 100644
--- a/tools/libs/saverestore/save.c
+++ b/tools/libs/saverestore/save.c
@@ -92,7 +92,7 @@ static int write_batch(struct xc_sr_context *ctx)
     void *guest_mapping = NULL;
     void **guest_data = NULL;
     void **local_pages = NULL;
-    int *errors = NULL, rc = -1;
+    int *errors = ctx->save.m->errors, rc = -1;
     unsigned int i, p, nr_pages = 0, nr_pages_mapped = 0;
     unsigned int nr_pfns = ctx->save.nr_batch_pfns;
     void *page, *orig_page;
@@ -105,8 +105,6 @@ static int write_batch(struct xc_sr_context *ctx)
 
     assert(nr_pfns != 0);
 
-    /* Errors from attempting to map the gfns. */
-    errors = malloc(nr_pfns * sizeof(*errors));
     /* Pointers to page data to send.  Mapped gfns or local allocations. */
     guest_data = calloc(nr_pfns, sizeof(*guest_data));
     /* Pointers to locally allocated pages.  Need freeing. */
@@ -114,7 +112,7 @@ static int write_batch(struct xc_sr_context *ctx)
     /* iovec[] for writev(). */
     iov = malloc((nr_pfns + 4) * sizeof(*iov));
 
-    if ( !errors || !guest_data || !local_pages || !iov )
+    if ( !guest_data || !local_pages || !iov )
     {
         ERROR("Unable to allocate arrays for a batch of %u pages",
               nr_pfns);
@@ -271,7 +269,6 @@ static int write_batch(struct xc_sr_context *ctx)
     free(iov);
     free(local_pages);
     free(guest_data);
-    free(errors);
 
     return rc;
 }



 


Rackspace

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