Replace old Perf macros with the new added ones. Cc: Liming Gao <liming....@intel.com> Cc: Star Zeng <star.z...@intel.com> Cc: Eric Dong <eric.d...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan...@intel.com> --- MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 7 +++++ MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 8 ++---- MdeModulePkg/Core/Dxe/Hand/DriverSupport.c | 8 +++--- MdeModulePkg/Core/Dxe/Image/Image.c | 30 +++++----------------- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +++--- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 17 ++++++------ MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 15 ++++------- MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 4 +-- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 2 +- .../Library/UefiBootManagerLib/BmConsole.c | 9 +++---- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 21 ++++++++------- 11 files changed, 53 insertions(+), 76 deletions(-)
diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c index 088cd810631..4c6ca761a60 100644 --- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c @@ -417,10 +417,11 @@ CoreDispatcher ( LIST_ENTRY *Link; EFI_CORE_DRIVER_ENTRY *DriverEntry; BOOLEAN ReadyToRun; EFI_EVENT DxeDispatchEvent; + PERF_FUNCTION_BEGIN (); if (gDispatcherRunning) { // // If the dispatcher is running don't let it be restarted. // @@ -582,10 +583,12 @@ CoreDispatcher ( // CoreCloseEvent (DxeDispatchEvent); gDispatcherRunning = FALSE; + PERF_FUNCTION_END (); + return ReturnStatus; } /** @@ -1435,17 +1438,21 @@ CoreFwVolEventProtocolNotify ( VOID CoreInitializeDispatcher ( VOID ) { + PERF_FUNCTION_BEGIN (); + mFwVolEvent = EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolume2ProtocolGuid, TPL_CALLBACK, CoreFwVolEventProtocolNotify, NULL, &mFwVolEventRegistration ); + + PERF_FUNCTION_END (); } // // Function only used in debug builds // diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 07c74034624..3f753738a27 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -299,12 +299,12 @@ DxeMain ( // // Call constructor for all libraries // ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST); - PERF_END (NULL,"PEI", NULL, 0) ; - PERF_START (NULL,"DXE", NULL, 0) ; + PERF_CROSSMODULE_END ("PEI"); + PERF_CROSSMODULE_BEGIN ("DXE"); // // Report DXE Core image information to the PE/COFF Extra Action Library // ZeroMem (&ImageContext, sizeof (ImageContext)); @@ -497,20 +497,16 @@ DxeMain ( ASSERT_EFI_ERROR (Status); // // Initialize the DXE Dispatcher // - PERF_START (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; CoreInitializeDispatcher (); - PERF_END (NULL,"CoreInitializeDispatcher", "DxeMain", 0) ; // // Invoke the DXE Dispatcher // - PERF_START (NULL, "CoreDispatcher", "DxeMain", 0); CoreDispatcher (); - PERF_END (NULL, "CoreDispatcher", "DxeMain", 0); // // Display Architectural protocols that were not loaded if this is DEBUG build // DEBUG_CODE_BEGIN (); diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c index 33dd0bd0b7c..ab3cc0c07e5 100644 --- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c +++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c @@ -625,32 +625,32 @@ CoreConnectSingleController ( DriverBinding = NULL; DriverFound = FALSE; for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && !DriverFound; Index++) { if (SortedDriverBindingProtocols[Index] != NULL) { DriverBinding = SortedDriverBindingProtocols[Index]; - PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0); + PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHandle, ControllerHandle); Status = DriverBinding->Supported( DriverBinding, ControllerHandle, RemainingDevicePath ); - PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0); + PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandle, ControllerHandle); if (!EFI_ERROR (Status)) { SortedDriverBindingProtocols[Index] = NULL; DriverFound = TRUE; // // A driver was found that supports ControllerHandle, so attempt to start the driver // on ControllerHandle. // - PERF_START (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0); + PERF_DRIVER_BINDING_START_BEGIN (DriverBinding->DriverBindingHandle, ControllerHandle); Status = DriverBinding->Start ( DriverBinding, ControllerHandle, RemainingDevicePath ); - PERF_END (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0); + PERF_DRIVER_BINDING_START_END (DriverBinding->DriverBindingHandle, ControllerHandle); if (!EFI_ERROR (Status)) { // // The driver was successfully started on ControllerHandle, so set a flag // diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index c49ddfcc81d..adeb4bf313a 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -1434,17 +1434,13 @@ CoreLoadImage ( IN UINTN SourceSize, OUT EFI_HANDLE *ImageHandle ) { EFI_STATUS Status; - UINT64 Tick; EFI_HANDLE Handle; - Tick = 0; - PERF_CODE ( - Tick = GetPerformanceCounter (); - ); + PERF_LOAD_IMAGE_BEGIN (NULL); Status = CoreLoadImageCommon ( BootPolicy, ParentImageHandle, FilePath, @@ -1463,12 +1459,11 @@ CoreLoadImage ( // ImageHandle will be valid only Status is success. // Handle = *ImageHandle; } - PERF_START (Handle, "LoadImage:", NULL, Tick); - PERF_END (Handle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (Handle); return Status; } @@ -1524,17 +1519,13 @@ CoreLoadImageEx ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL, IN UINT32 Attribute ) { EFI_STATUS Status; - UINT64 Tick; EFI_HANDLE Handle; - Tick = 0; - PERF_CODE ( - Tick = GetPerformanceCounter (); - ); + PERF_LOAD_IMAGE_BEGIN (NULL); Status = CoreLoadImageCommon ( TRUE, ParentImageHandle, FilePath, @@ -1553,12 +1544,11 @@ CoreLoadImageEx ( // ImageHandle will be valid only Status is success. // Handle = *ImageHandle; } - PERF_START (Handle, "LoadImage:", NULL, Tick); - PERF_END (Handle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (Handle); return Status; } @@ -1592,14 +1582,12 @@ CoreStartImage ( EFI_STATUS Status; LOADED_IMAGE_PRIVATE_DATA *Image; LOADED_IMAGE_PRIVATE_DATA *LastImage; UINT64 HandleDatabaseKey; UINTN SetJumpFlag; - UINT64 Tick; EFI_HANDLE Handle; - Tick = 0; Handle = ImageHandle; Image = CoreLoadedImageInfo (ImageHandle); if (Image == NULL || Image->Started) { return EFI_INVALID_PARAMETER; @@ -1619,13 +1607,11 @@ CoreStartImage ( DEBUG ((EFI_D_ERROR, "Image type %s can't be started ", GetMachineTypeName(Image->Machine))); DEBUG ((EFI_D_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCoreImageMachineType))); return EFI_UNSUPPORTED; } - PERF_CODE ( - Tick = GetPerformanceCounter (); - ); + PERF_START_IMAGE_BEGIN (Handle); // // Push the current start image context, and // link the current image to the head. This is the @@ -1645,12 +1631,11 @@ CoreStartImage ( if (Image->JumpBuffer == NULL) { // // Image may be unloaded after return with failure, // then ImageHandle may be invalid, so use NULL handle to record perf log. // - PERF_START (NULL, "StartImage:", NULL, Tick); - PERF_END (NULL, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (NULL); // // Pop the current start image context // mCurrentImage = LastImage; @@ -1761,12 +1746,11 @@ CoreStartImage ( } // // Done // - PERF_START (Handle, "StartImage:", NULL, Tick); - PERF_END (Handle, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (Handle); return Status; } /** Terminates the currently loaded EFI image and returns control to boot services. diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index 0ac3fdde6a9..c4f629dadff 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -998,13 +998,13 @@ PeiDispatcher ( // // Call the PEIM entry point // PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint; - PERF_START (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_BEGIN (PeimFileHandle); PeimEntryPoint(PeimFileHandle, (const EFI_PEI_SERVICES **) &Private->Ps); - PERF_END (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_END (PeimFileHandle); } // // Process the Notify list and dispatch any notifies for // newly installed PPIs. @@ -1107,11 +1107,11 @@ PeiDispatcher ( if (Status == EFI_SUCCESS) { // // The PEIM has its dependencies satisfied, and its entry point // has been found, so invoke it. // - PERF_START (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_BEGIN (PeimFileHandle); REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN), (VOID *)(&PeimFileHandle), @@ -1143,11 +1143,11 @@ PeiDispatcher ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END), (VOID *)(&PeimFileHandle), sizeof (PeimFileHandle) ); - PERF_END (PeimFileHandle, "PEIM", NULL, 0); + PERF_START_IMAGE_END (PeimFileHandle); } } PeiCheckAndSwitchStack (SecCoreData, Private); diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index 775bf18ce93..a52e6f02017 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -350,22 +350,21 @@ PeiCore ( // // Update performance measurements // if (OldCoreData == NULL) { - PERF_START (NULL, "SEC", NULL, 1); - PERF_END (NULL, "SEC", NULL, 0); + PERF_EVENT ("SEC"); // Means the end of SEC phase. // // If first pass, start performance measurement. // - PERF_START (NULL,"PEI", NULL, 0); - PERF_START (NULL,"PreMem", NULL, 0); + PERF_CROSSMODULE_BEGIN ("PEI"); + PERF_INMODULE_BEGIN ("PreMem"); } else { - PERF_END (NULL,"PreMem", NULL, 0); - PERF_START (NULL,"PostMem", NULL, 0); + PERF_INMODULE_END ("PreMem"); + PERF_INMODULE_BEGIN ("PostMem"); } // // Complete PEI Core Service initialization // @@ -409,19 +408,19 @@ PeiCore ( } // // Alert any listeners that there is permanent memory available // - PERF_START (NULL,"DisMem", NULL, 0); + PERF_INMODULE_BEGIN ("DisMem"); Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi); // // Process the Notify list and dispatch any notifies for the Memory Discovered PPI // ProcessNotifyList (&PrivateData); - PERF_END (NULL,"DisMem", NULL, 0); + PERF_INMODULE_END ("DisMem"); } // // Call PEIM dispatcher // @@ -435,11 +434,11 @@ PeiCore ( } // // Measure PEI Core execution time. // - PERF_END (NULL, "PostMem", NULL, 0); + PERF_INMODULE_END ("PostMem"); // // Lookup DXE IPL PPI // Status = PeiServicesLocatePpi ( diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index f32bbbd1b4b..0b3b5924d38 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -319,17 +319,13 @@ SmmLoadImage ( EFI_DEVICE_PATH_PROTOCOL *FilePath; EFI_DEVICE_PATH_PROTOCOL *OriginalFilePath; EFI_DEVICE_PATH_PROTOCOL *HandleFilePath; EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - UINT64 Tick; - Tick = 0; - PERF_CODE ( - Tick = GetPerformanceCounter (); - ); - + PERF_LOAD_IMAGE_BEGIN (DriverEntry->ImageHandle); + Buffer = NULL; Size = 0; Fv = DriverEntry->Fv; NameGuid = &DriverEntry->FileName; FilePath = DriverEntry->FvFileDevicePath; @@ -639,12 +635,11 @@ SmmLoadImage ( &gEfiLoadedImageProtocolGuid, EFI_NATIVE_INTERFACE, &DriverEntry->SmmLoadedImage ); - PERF_START (DriverEntry->ImageHandle, "LoadImage:", NULL, Tick); - PERF_END (DriverEntry->ImageHandle, "LoadImage:", NULL, 0); + PERF_LOAD_IMAGE_END (DriverEntry->ImageHandle); // // Print the load address and the PDB file name if it is available // @@ -907,13 +902,13 @@ SmmDispatcher ( // // For each SMM driver, pass NULL as ImageHandle // RegisterSmramProfileImage (DriverEntry, TRUE); - PERF_START (DriverEntry->ImageHandle, "StartImage:", NULL, 0); + PERF_START_IMAGE_BEGIN (DriverEntry->ImageHandle); Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, gST); - PERF_END (DriverEntry->ImageHandle, "StartImage:", NULL, 0); + PERF_START_IMAGE_END (DriverEntry->ImageHandle); if (EFI_ERROR(Status)){ UnregisterSmramProfileImage (DriverEntry, TRUE); SmmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage); // // Uninstall LoadedImage diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c index 686b9b45a55..45f40e0e60c 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c @@ -642,11 +642,11 @@ SmmEntryPoint ( BOOLEAN InLegacyBoot; BOOLEAN IsOverlapped; VOID *CommunicationBuffer; UINTN BufferSize; - PERF_START (NULL, "SMM", NULL, 0) ; + PERF_INMODULE_BEGIN ("SMM"); // // Update SMST with contents of the SmmEntryContext structure // gSmmCoreSmst.SmmStartupThisAp = SmmEntryContext->SmmStartupThisAp; @@ -737,11 +737,11 @@ SmmEntryPoint ( // Clear the InSmm flag as we are going to leave SMM // gSmmCorePrivate->InSmm = FALSE; } - PERF_END (NULL, "SMM", NULL, 0) ; + PERF_INMODULE_END ("SMM"); } /** Install LoadedImage protocol for SMM Core. **/ diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index b842d5824ae..59bd1e4c6c0 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -43,11 +43,11 @@ BmEndOfBdsPerfCode ( ) { // // Record the performance data for End of BDS // - PERF_END(NULL, "BDS", NULL, 0); + PERF_CROSSMODULE_END("BDS"); return ; } /** diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c index 80511814eec..d85b603d64a 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c @@ -720,27 +720,24 @@ EfiBootManagerConnectAllDefaultConsoles ( Status = EfiBootManagerConnectConsoleVariable (ConOut); if (!EFI_ERROR (Status)) { OneConnected = TRUE; } - PERF_START (NULL, "ConOutReady", "BDS", 1); - PERF_END (NULL, "ConOutReady", "BDS", 0); + PERF_EVENT ("ConOutReady"); Status = EfiBootManagerConnectConsoleVariable (ConIn); if (!EFI_ERROR (Status)) { OneConnected = TRUE; } - PERF_START (NULL, "ConInReady", "BDS", 1); - PERF_END (NULL, "ConInReady", "BDS", 0); + PERF_EVENT ("ConInReady"); Status = EfiBootManagerConnectConsoleVariable (ErrOut); if (!EFI_ERROR (Status)) { OneConnected = TRUE; } - PERF_START (NULL, "ErrOutReady", "BDS", 1); - PERF_END (NULL, "ErrOutReady", "BDS", 0); + PERF_EVENT ("ErrOutReady"); SystemTableUpdated = FALSE; // // Fill console handles in System Table if no console device assignd. // diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 3191a986304..acb25abfcd4 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -723,12 +723,12 @@ BdsEntry ( BootSuccess = FALSE; // // Insert the performance probe // - PERF_END (NULL, "DXE", NULL, 0); - PERF_START (NULL, "BDS", NULL, 0); + PERF_CROSSMODULE_END("DXE"); + PERF_CROSSMODULE_BEGIN("BDS"); DEBUG ((EFI_D_INFO, "[Bds] Entry...\n")); // // Fill in FirmwareVendor and FirmwareRevision from PCDs // @@ -886,13 +886,13 @@ BdsEntry ( // > Register new Driver#### or Boot#### // > Register new Key####: e.g.: F12 // > Signal ReadyToLock event // > Authentication action: 1. connect Auth devices; 2. Identify auto logon user. // - PERF_START (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0); + PERF_INMODULE_BEGIN("PlatformBootManagerBeforeConsole"); PlatformBootManagerBeforeConsole (); - PERF_END (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0); + PERF_INMODULE_END("PlatformBootManagerBeforeConsole"); // // Initialize hotkey service // EfiBootManagerStartHotkeyService (&HotkeyTriggered); @@ -905,21 +905,21 @@ BdsEntry ( EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); // // Connect consoles // - PERF_START (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0); + PERF_INMODULE_BEGIN("EfiBootManagerConnectAllDefaultConsoles"); if (PcdGetBool (PcdConInConnectOnDemand)) { EfiBootManagerConnectConsoleVariable (ConOut); EfiBootManagerConnectConsoleVariable (ErrOut); // // Do not connect ConIn devices when lazy ConIn feature is ON. // } else { EfiBootManagerConnectAllDefaultConsoles (); } - PERF_END (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0); + PERF_INMODULE_END("EfiBootManagerConnectAllDefaultConsoles"); // // Do the platform specific action after the console is ready // Possible things that can be done in PlatformBootManagerAfterConsole: // > Console post action: @@ -928,13 +928,13 @@ BdsEntry ( // > Run diagnostics like memory testing // > Connect certain devices // > Dispatch aditional option roms // > Special boot: e.g.: USB boot, enter UI // - PERF_START (NULL, "PlatformBootManagerAfterConsole", "BDS", 0); + PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole"); PlatformBootManagerAfterConsole (); - PERF_END (NULL, "PlatformBootManagerAfterConsole", "BDS", 0); + PERF_INMODULE_END("PlatformBootManagerAfterConsole"); // // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot // DataSize = sizeof (UINT64); Status = gRT->GetVariable ( @@ -1023,14 +1023,13 @@ BdsEntry ( EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); // // Execute Key#### // - PERF_START (NULL, "BdsWait", "BDS", 0); + PERF_INMODULE_BEGIN ("BdsWait"); BdsWait (HotkeyTriggered); - PERF_END (NULL, "BdsWait", "BDS", 0); - + PERF_INMODULE_END ("BdsWait"); // // BdsReadKeys() can be removed after all keyboard drivers invoke callback in timer callback. // BdsReadKeys (); -- 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel