From 5c0687ccc27a427e5e50f35e593814055d714d9b Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Mon, 19 Mar 2012 02:52:15 +0000 Subject: [PATCH] Remove the useless performance logging code in BootScriptExecutorDxe driver and record S3 "ScriptExec" performance log before and after executing BootScriptExecutorEntrypoint in S3Reusme2Pei driver. Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13108 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BootScriptExecutorDxe.inf | 1 - .../BootScriptExecutorDxe/ScriptExecute.c | 112 +----------------- .../BootScriptExecutorDxe/ScriptExecute.h | 2 - .../Universal/Acpi/S3Resume2Pei/S3Resume.c | 4 + 4 files changed, 5 insertions(+), 114 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf index 592d010517..2fbbdb2e31 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf @@ -64,7 +64,6 @@ UefiBootServicesTableLib UefiRuntimeServicesTableLib CacheMaintenanceLib - PerformanceLib UefiLib DebugAgentLib LockBoxLib diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c index d4d2a93492..933c328262 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c @@ -4,7 +4,7 @@ This driver is dispatched by Dxe core and the driver will reload itself to ACPI NVS memory in the entry point. The functionality is to interpret and restore the S3 boot script -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -18,87 +18,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "ScriptExecute.h" -EFI_PHYSICAL_ADDRESS mPerfDataMemAddress; -UINT64 mS3BootScriptEntryTick; -UINT64 mScriptStartTick; -UINT64 mScriptEndTick; - EFI_GUID mBootScriptExecutorImageGuid = { 0x9a8d3433, 0x9fe8, 0x42b6, 0x87, 0xb, 0x1e, 0x31, 0xc8, 0x4e, 0xbe, 0x3b }; -/** - The event callback is used to get the base address of boot performance data structure on - LegacyBoot event and ExitBootServices event. - - @param Event The event handle. - @param Context The event context. - -**/ -VOID -EFIAPI -OnBootEvent ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - EFI_STATUS Status; - UINTN VarSize; - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = gRT->GetVariable ( - L"PerfDataMemAddr", - &gPerformanceProtocolGuid, - NULL, - &VarSize, - &mPerfDataMemAddress - ); - if (EFI_ERROR (Status)) { - mPerfDataMemAddress = 0; - } -} - -/** - Record S3 Script execution time and adjust total S3 resume time for script running. -**/ -VOID -WriteToOsS3PerformanceData ( - VOID - ) -{ - UINT64 Ticker; - UINT64 StartValue; - UINT64 EndValue; - UINT64 Freq; - UINT64 ScriptExecuteTicks; - PERF_HEADER *PerfHeader; - PERF_DATA *PerfData; - - Ticker = GetPerformanceCounter (); - - PerfHeader = (PERF_HEADER *)(UINTN)mPerfDataMemAddress; - if (PerfHeader == NULL) { - return; - } - - Freq = GetPerformanceCounterProperties (&StartValue, &EndValue); - Freq = DivU64x32 (Freq, 1000); - - if (EndValue >= StartValue) { - ScriptExecuteTicks = mScriptEndTick - mScriptStartTick; - PerfHeader->S3Resume += Ticker - mS3BootScriptEntryTick; - } else { - ScriptExecuteTicks = mScriptStartTick - mScriptEndTick; - PerfHeader->S3Resume += mS3BootScriptEntryTick - Ticker; - } - if (PerfHeader->S3EntryNum < PERF_PEI_ENTRY_MAX_NUM) { - PerfData = &PerfHeader->S3Entry[PerfHeader->S3EntryNum]; - PerfData->Duration = (UINT32) DivU64x32 (ScriptExecuteTicks, (UINT32) Freq);; - AsciiStrnCpy (PerfData->Token, "ScriptExec", PERF_TOKEN_LENGTH); - PerfHeader->S3EntryNum++; - } -} - /** Entry function of Boot script exector. This function will be executed in S3 boot path. @@ -123,10 +46,6 @@ S3BootScriptExecutorEntryFunction ( UINTN TempStack[0x10]; UINTN AsmTransferControl16Address; - PERF_CODE ( - mS3BootScriptEntryTick = GetPerformanceCounter (); - ); - // // Disable interrupt of Debug timer, since new IDT table cannot handle it. // @@ -146,13 +65,7 @@ S3BootScriptExecutorEntryFunction ( // Because not install BootScriptExecute PPI(used just in this module), So just pass NULL // for that parameter. // - PERF_CODE ( - mScriptStartTick = GetPerformanceCounter (); - ); Status = S3BootScriptExecute (); - PERF_CODE ( - mScriptEndTick = GetPerformanceCounter (); - ); if (EFI_ERROR (Status)) { return Status; } @@ -218,10 +131,6 @@ S3BootScriptExecutorEntryFunction ( return EFI_UNSUPPORTED; } - PERF_CODE ( - WriteToOsS3PerformanceData (); - ); - if (Facs->XFirmwareWakingVector != 0) { // // Switch to native waking vector @@ -449,25 +358,6 @@ BootScriptExecutorEntryPoint ( Status = SetLockBoxAttributes (&gEfiBootScriptExecutorContextGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE); ASSERT_EFI_ERROR (Status); - PERF_CODE ( - EFI_EVENT Event; - - gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - OnBootEvent, - NULL, - &gEfiEventExitBootServicesGuid, - &Event - ); - - EfiCreateEventLegacyBootEx( - TPL_NOTIFY, - OnBootEvent, - NULL, - &Event - ); - ); } return EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h index 8e4b328db7..707ab8ca68 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.h @@ -31,7 +31,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include @@ -41,7 +40,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include /** a ASM function to transfer control to OS. diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index c0680bf771..50b2f7bc0a 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -390,6 +390,8 @@ S3ResumeBootOs ( // AsmWriteIdtr (&PeiS3ResumeState->Idtr); + PERF_END (NULL, "ScriptExec", NULL, 0); + // // Install BootScriptDonePpi // @@ -742,6 +744,8 @@ S3ResumeExecuteBootScript ( // AsmReadIdtr (&PeiS3ResumeState->Idtr); + PERF_START (NULL, "ScriptExec", NULL, 0); + if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { // // X64 S3 Resume -- 2.39.2