[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v20210601 18/38] tools/guest: restore: move pfns array
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; }
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |