On 10/9/23 02:07, Taylor Beebe wrote: > When page/pool protections are active, the GCD sync process takes > quite a bit longer than normal. This behavior is primarily due to > a function which dumps the GCD memory map to the console. This > dump function runs only on DEBUG builds but will iterate through > the GCD memory map dozens of times even when the print level doesn't > include DEBUG_GCD. This patch adds a check for the DEBUG_GCD print > level before dumping the GCD memory map which saves several seconds > during boot when page/pool protections are active. > > Signed-off-by: Taylor Beebe <taylor.d.be...@gmail.com> > Cc: Jian J Wang <jian.j.w...@intel.com> > Cc: Liming Gao <gaolim...@byosoft.com.cn> > Cc: Dandan Bi <dandan...@intel.com> > --- > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 4 ++++ > MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + > 2 files changed, 5 insertions(+) > > diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > index 72bd036eab1e..392586d5b17c 100644 > --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > @@ -150,6 +150,10 @@ CoreDumpGcdMemorySpaceMap ( > EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; > UINTN Index; > > + if ((PcdGet32 (PcdDebugPrintErrorLevel) & DEBUG_GCD) == 0) { > + return; > + } > + > Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); > ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL); > > diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf > b/MdeModulePkg/Core/Dxe/DxeMain.inf > index 35d5bf0dee6f..6c896a0e7f0f 100644 > --- a/MdeModulePkg/Core/Dxe/DxeMain.inf > +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf > @@ -187,6 +187,7 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask > ## CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard > ## CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth > ## CONSUMES > + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel > ## CONSUMES > > # [Hob] > # RESOURCE_DESCRIPTOR ## CONSUMES
IMO we could avoid the direct PCD consumption here, and write if (!DebugPrintLevelEnabled (DEBUG_GCD) || ((GetDebugPrintErrorLevel () & DEBUG_GCD) == 0)) { return; } In practice, most of the time, the first call will check PcdFixedDebugPrintErrorLevel, and the second call will check PcdDebugPrintErrorLevel. Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109437): https://edk2.groups.io/g/devel/message/109437 Mute This Topic: https://groups.io/mt/101843348/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-