From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: michael.d.kinney@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Thu, 25 Apr 2019 15:33:27 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2019 15:33:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,394,1549958400"; d="scan'208";a="145895204" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga007.fm.intel.com with ESMTP; 25 Apr 2019 15:33:26 -0700 Received: from orsmsx162.amr.corp.intel.com (10.22.240.85) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 25 Apr 2019 15:33:26 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.24]) by ORSMSX162.amr.corp.intel.com ([169.254.3.253]) with mapi id 14.03.0415.000; Thu, 25 Apr 2019 15:33:26 -0700 From: "Michael D Kinney" To: "Bi, Dandan" , "devel@edk2.groups.io" , "Kinney, Michael D" CC: "Gao, Liming" , "Dong, Eric" Subject: Re: [patch] MdeModulePkg/HiiDB: Minimize memory allocation times after ReadyToBoot Thread-Topic: [patch] MdeModulePkg/HiiDB: Minimize memory allocation times after ReadyToBoot Thread-Index: AQHU+xg6hiEloQ0tikuclIWPE9fONKZNdv9w Date: Thu, 25 Apr 2019 22:33:25 +0000 Message-ID: References: <20190425033728.32212-1-dandan.bi@intel.com> In-Reply-To: <20190425033728.32212-1-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Return-Path: michael.d.kinney@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Michael D Kinney > -----Original Message----- > From: Bi, Dandan > Sent: Wednesday, April 24, 2019 8:37 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, > Liming ; Dong, Eric > > Subject: [patch] MdeModulePkg/HiiDB: Minimize memory > allocation times after ReadyToBoot >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1597 >=20 > 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. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Dandan Bi > --- > .../Universal/HiiDatabaseDxe/Database.c | 24 > +++++++++++++------ > 1 file changed, 17 insertions(+), 7 deletions(-) >=20 > diff --git > a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c > b/MdeModulePkg/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,&ConfigAltResp); >=20 > if (!EFI_ERROR (Status)){ > ConfigSize =3D StrSize(ConfigAltResp); > if (ConfigSize > gConfigRespSize){ > - gConfigRespSize =3D ConfigSize; > + // > + // Do 25% overallocation to minimize the number of > memory allocations 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(ConfigSize); > + gRTConfigRespBuffer =3D (EFI_STRING) > AllocateRuntimeZeroPool (gConfigRespSize); > if (gRTConfigRespBuffer =3D=3D NULL){ > FreePool(ConfigAltResp); > - DEBUG ((DEBUG_ERROR, "Not enough memory resource > to get the ConfigResp 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, DatabaseInfo); >=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 and cause S4 resume issue. > + // > + gDatabaseInfoSize =3D DatabaseInfoSize + > (DatabaseInfoSize >> 2); > if (gRTDatabaseInfoBuffer !=3D NULL){ > FreePool(gRTDatabaseInfoBuffer); > + DEBUG ((DEBUG_WARN, "[HiiDatabase]: Memory > allocation is required after 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 HiiDatabase info.\n")); > + DEBUG ((DEBUG_ERROR, "[HiiDatabase]: No enough > memory resource to store the HiiDatabase info.\n")); > return EFI_OUT_OF_RESOURCES; > } > } else { > ZeroMem(gRTDatabaseInfoBuffer,gDatabaseInfoSize); > } > -- > 2.18.0.windows.1