From nobody Mon Feb 9 09:22:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1603992058; cv=none; d=zohomail.com; s=zohoarc; b=Tuc3iX372LSgPhISPMUmu+CvuKsIp4+BjhXkbLW+wOCz6zN0dF5njR6Shka1ksnJdvxC3+n8JXAM5XH4cBKZYz97tPhWw816Oi8hwOmptXqoNAaA1lZEYGJ4FD981L56ZFotLwfFVviIt5fKPN16zM3toNV1g4nCTtEwGa73kXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603992058; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VVfW+oAH1Frox7ej6KApgNQS/Q90zBjaSWimvZM/Rz8=; b=OjaEbtKUBIZXi6I/1c0os/E3oIK2ZYH21+mD3KVJEkVf/7tW2FVLGOm8bqVo2sCItBebbIxzpMyExZjz2i3WwssnXoCQGrEZoLtTk8rT4q7NL4XoeGdtVC49kqf2+LZhy708bJsfMf7sCFLMpZ41JMXdyJwyrWkHkhTokWwMqCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1603992058610117.90601307377528; Thu, 29 Oct 2020 10:20:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.14427.35715 (Exim 4.92) (envelope-from ) id 1kYBbO-000427-Tz; Thu, 29 Oct 2020 17:20:42 +0000 Received: by outflank-mailman (output) from mailman id 14427.35715; Thu, 29 Oct 2020 17:20:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kYBbO-00041n-OI; Thu, 29 Oct 2020 17:20:42 +0000 Received: by outflank-mailman (input) for mailman id 14427; Thu, 29 Oct 2020 17:20:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kYBbN-0003MC-Li for xen-devel@lists.xenproject.org; Thu, 29 Oct 2020 17:20:41 +0000 Received: from mo4-p02-ob.smtp.rzone.de (unknown [85.215.255.82]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b1211aba-36a0-4d14-9c12-d0ef84df3695; Thu, 29 Oct 2020 17:20:19 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 47.3.0 DYNA|AUTH) with ESMTPSA id j0b1afw9THKD3fH (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Thu, 29 Oct 2020 18:20:13 +0100 (CET) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kYBbN-0003MC-Li for xen-devel@lists.xenproject.org; Thu, 29 Oct 2020 17:20:41 +0000 Received: from mo4-p02-ob.smtp.rzone.de (unknown [85.215.255.82]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b1211aba-36a0-4d14-9c12-d0ef84df3695; Thu, 29 Oct 2020 17:20:19 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 47.3.0 DYNA|AUTH) with ESMTPSA id j0b1afw9THKD3fH (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Thu, 29 Oct 2020 18:20:13 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b1211aba-36a0-4d14-9c12-d0ef84df3695 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1603992018; s=strato-dkim-0002; d=aepfle.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=VVfW+oAH1Frox7ej6KApgNQS/Q90zBjaSWimvZM/Rz8=; b=TkkWMSXeFN2eROBRvYQywqH0q0qV5fFJK7u/XrU/lNwp2dPTpeaAsEx2FJNQzWfMC3 NDTxq9YTAmUp6nQDyAHjWRJlTn1XaODMO0lhzm9VrpQjQIRTKfJZCWLEEeD8JXzXaRMn PTOkpnCh0HneHbEaPr0fXD3M1P3rF+rMwSa3EPUWjpv5kBbsu/2i+87lfSaYRGrBcY49 +0wS65vNO5hVmAszhdW8WnhWK2GDZxJb7CmYSu6FgCH6AbHxVvUnhl3kkg+oVru0ibC0 nGJrLNRSvHN2Y/hJ+6ctaCyIuZY/WuIiI+nrjkLctW/dX81kQV6CFfX2nGQLbnkLedsp oLxQ== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzBW/OdlBZQ4AHSS3G1Jjw==" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: xen-devel@lists.xenproject.org Cc: Olaf Hering , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v1 12/23] tools/guest: save: move rec_pfns array Date: Thu, 29 Oct 2020 18:19:52 +0100 Message-Id: <20201029172004.17219-13-olaf@aepfle.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029172004.17219-1-olaf@aepfle.de> References: <20201029172004.17219-1-olaf@aepfle.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Remove allocation from hotpath, move rec_pfns array into preallocated space. Signed-off-by: Olaf Hering --- tools/libs/guest/xg_sr_common.h | 2 ++ tools/libs/guest/xg_sr_save.c | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_commo= n.h index f315b4f526..81158a4f4d 100644 --- a/tools/libs/guest/xg_sr_common.h +++ b/tools/libs/guest/xg_sr_common.h @@ -221,6 +221,8 @@ struct xc_sr_save_arrays { int errors[MAX_BATCH_SIZE]; /* write_batch: iovec[] for writev(). */ struct iovec iov[MAX_BATCH_SIZE + 4]; + /* write_batch */ + uint64_t rec_pfns[MAX_BATCH_SIZE]; }; =20 struct xc_sr_restore_arrays { diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c index 385a591332..4d7fbe09ed 100644 --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -96,7 +96,7 @@ static int write_batch(struct xc_sr_context *ctx) unsigned int i, p, nr_pages =3D 0, nr_pages_mapped =3D 0; unsigned int nr_pfns =3D ctx->save.nr_batch_pfns; void *page, *orig_page; - uint64_t *rec_pfns =3D NULL; + uint64_t *rec_pfns =3D ctx->save.m->rec_pfns; struct iovec *iov =3D ctx->save.m->iov; int iovcnt =3D 0; struct xc_sr_rec_page_data_header hdr =3D { 0 }; struct xc_sr_record rec =3D { @@ -201,14 +201,6 @@ static int write_batch(struct xc_sr_context *ctx) } } =20 - rec_pfns =3D malloc(nr_pfns * sizeof(*rec_pfns)); - if ( !rec_pfns ) - { - ERROR("Unable to allocate %zu bytes of memory for page data pfn li= st", - nr_pfns * sizeof(*rec_pfns)); - goto err; - } - hdr.count =3D nr_pfns; =20 rec.length =3D sizeof(hdr); @@ -259,7 +251,6 @@ static int write_batch(struct xc_sr_context *ctx) rc =3D ctx->save.nr_batch_pfns =3D 0; =20 err: - free(rec_pfns); if ( guest_mapping ) xenforeignmemory_unmap(xch->fmem, guest_mapping, nr_pages_mapped); for ( i =3D 0; local_pages && i < nr_pfns; ++i )