From nobody Sat May 11 11:02:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+39535+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39535+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1556163460; cv=none; d=zoho.com; s=zohoarc; b=fWBSMZ1LC3k65cfDXT3TM0h+UZec04x0U3HCnxKauX0CL0h71XeSG5EyhWORzBRjB7Nw6hZG7HgPHCLA3KZ7k1CTjqhjgkOohjGSFIk75LMexiy2oiOH85IYsKI8uxJd48AfiQEs4JHzIJ8oIn+F374yCEwrgWBCaDDPl61YtDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556163460; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=esizkdoQY+X+zwhxKXD/V24RxeqH9IJjL/hTyPemnY0=; b=DsRZPFBJGTJ6Q+2HEALq176s6h3BxafwLA7S9gp6GTmQpXN7TS9bdaO+sdIT6Qc1/WWhZYFX9aJY9lqXwMMSIZjlYFMOczr7Tksdraz3flNsCaP9S/7R7g0XbkvzDTApT5wSxIO8sC6GwcxajhlUjq2OV2Gt3EzXLX2hAstOd6Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39535+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1556163460530255.8984236311112; Wed, 24 Apr 2019 20:37:40 -0700 (PDT) Return-Path: X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Wed, 24 Apr 2019 20:37:39 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 20:37:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,392,1549958400"; d="scan'208";a="294349683" X-Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.147]) by orsmga004.jf.intel.com with ESMTP; 24 Apr 2019 20:37:37 -0700 From: "Dandan Bi" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Eric Dong Subject: [edk2-devel] [patch] MdeModulePkg/HiiDB: Minimize memory allocation times after ReadyToBoot Date: Thu, 25 Apr 2019 11:37:28 +0800 Message-Id: <20190425033728.32212-1-dandan.bi@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dandan.bi@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1556163460; bh=MJtLc1v7uRD7kkPwlhlQnvHMvuCykW3V+0JrnMCJ8RI=; h=Cc:Date:From:Reply-To:Subject:To; b=MulT+gOrFZG8psHU1nR+/DPEPERAi2vHhpGjCPCeQkgmeYpHGQXeNpauhtzyny4Foeb QzNFjiePM7EhtjwPJr/jjiwbC2PmX2PMWmhJyxL3b7ndgF0dMorgS9Ups6XTEUxDrf/l7 3M8EQMfpJWnS5v3NC6o80NSxZd912jKGx/0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1597 Currently RTData are allocated at/after ReadyToBoot to store the contents in HiiDatabase and the HII configurations for OS runtime utilization. Some platforms may meet S4 resume issue since the allocation after ReadyToBoot cause memory map change. Now this patch to do some overallocation to minimize the number of memory allocations after ReadyToBoot and also add warning message when do allocation after ReadyToBoot. Cc: Michael D Kinney Cc: Liming Gao Cc: Eric Dong Signed-off-by: Dandan Bi Reviewed-by: Eric Dong Reviewed-by: Michael D Kinney --- .../Universal/HiiDatabaseDxe/Database.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePk= g/Universal/HiiDatabaseDxe/Database.c index 6da0e30c98..d3791ca68b 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -1,9 +1,9 @@ /** @file Implementation for EFI_HII_DATABASE_PROTOCOL. =20 -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 =20 @@ -3361,18 +3361,23 @@ HiiGetConfigRespInfo( Status =3D HiiConfigRoutingExportConfig(&Private->ConfigRouting,&ConfigA= ltResp); =20 if (!EFI_ERROR (Status)){ ConfigSize =3D StrSize(ConfigAltResp); if (ConfigSize > gConfigRespSize){ - gConfigRespSize =3D ConfigSize; + // + // Do 25% overallocation to minimize the number of memory allocation= s after ReadyToBoot. + // Since lots of allocation after ReadyToBoot may change memory map = and cause S4 resume issue. + // + gConfigRespSize =3D ConfigSize + (ConfigSize >> 2); if (gRTConfigRespBuffer !=3D NULL){ FreePool(gRTConfigRespBuffer); + DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory allocation is required = after ReadyToBoot, which may change memory map and cause S4 resume issue.\n= ")); } - gRTConfigRespBuffer =3D (EFI_STRING)AllocateRuntimeZeroPool(ConfigSi= ze); + gRTConfigRespBuffer =3D (EFI_STRING) AllocateRuntimeZeroPool (gConfi= gRespSize); if (gRTConfigRespBuffer =3D=3D NULL){ FreePool(ConfigAltResp); - DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the Config= Resp string.\n")); + DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to = store the ConfigResp string.\n")); return EFI_OUT_OF_RESOURCES; } } else { ZeroMem(gRTConfigRespBuffer,gConfigRespSize); } @@ -3412,17 +3417,22 @@ HiiGetDatabaseInfo( Status =3D HiiExportPackageLists(This, NULL, &DatabaseInfoSize, Database= Info); =20 ASSERT(Status =3D=3D EFI_BUFFER_TOO_SMALL); =20 if(DatabaseInfoSize > gDatabaseInfoSize ) { - gDatabaseInfoSize =3D DatabaseInfoSize; + // + // Do 25% overallocation to minimize the number of memory allocations = after ReadyToBoot. + // Since lots of allocation after ReadyToBoot may change memory map an= d cause S4 resume issue. + // + gDatabaseInfoSize =3D DatabaseInfoSize + (DatabaseInfoSize >> 2); if (gRTDatabaseInfoBuffer !=3D NULL){ FreePool(gRTDatabaseInfoBuffer); + DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory allocation is required af= ter ReadyToBoot, which may change memory map and cause S4 resume issue.\n")= ); } - gRTDatabaseInfoBuffer =3D AllocateRuntimeZeroPool(DatabaseInfoSize); + gRTDatabaseInfoBuffer =3D AllocateRuntimeZeroPool (gDatabaseInfoSize); if (gRTDatabaseInfoBuffer =3D=3D NULL){ - DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the HiiDatab= ase info.\n")); + DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough memory resource to st= ore the HiiDatabase info.\n")); return EFI_OUT_OF_RESOURCES; } } else { ZeroMem(gRTDatabaseInfoBuffer,gDatabaseInfoSize); } --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39535): https://edk2.groups.io/g/devel/message/39535 Mute This Topic: https://groups.io/mt/31338933/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-