> On Jun 30, 2016, at 12:05 AM, Yao, Jiewen <jiewen....@intel.com> wrote:
> 
> Yes, Andrew. You are right.
> We encounter similar problem, but it seems MSVC _ReturnAddress() does not 
> take parameter.
>  #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)
> 

For GCC family you can potentially get more info. 

#define RETURN_ADDRESS(L)     __builtin_return_address (L)

> So we enhanced MemoryAllocationLib to support add record from 
> MemoryAllocationLib.
> 

Does that mean the logging gets moved to the library? Or does the library log 
just update the log in the DXE Core?

> The final log is like this:
> 
>  Count            Size                   RVA              Action
> ==========  ==================     ================== 
> (================================)
> 0x0000006B  0x000000000001D31F <== 0x000000000000AE7C (gBS->AllocatePool) 
> (InternalAllocatePool() - 
> c:\home\edk-ii\mdemodulepkg\library\smmmemoryallocationlibprofile\memoryallocationlib.c:567)
> 0x00000001  0x0000000000000020 <== 0x000000000000BCB8 (Lib:AllocatePool) 
> (SmmMemLibConstructor() - 
> c:\home\edk-ii\mdepkg\library\smmmemlib\smmmemlib.c:309)
> 0x00000001  0x0000000000000070 <== 0x0000000000007F2D 
> (Lib:AllocateZeroRuntimePool) (VariableCommonInitialize() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:4055)
> 0x00000001  0x000000000000C000 <== 0x000000000000715A 
> (Lib:AllocateZeroRuntimePool) (InitNonVolatileVariableStore() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:3692)
> 0x00000001  0x0000000000010400 <== 0x0000000000008121 
> (Lib:AllocateRuntimePool) (VariableCommonInitialize() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:4113)
> 0x00000001  0x0000000000000404 <== 0x0000000000002957 (gBS->AllocatePool) 
> (VariableServiceInitialize() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variablesmm.c:956)
> 0x00000007  0x00000000000001CE <== 0x000000000000C42E 
> (Lib:AllocateZeroRuntimePool) (VarCheckLibVariablePropertySet() - 
> c:\home\edk-ii\mdemodulepkg\library\varchecklib\varchecklib.c:521)
> 0x00000001  0x0000000000000020 <== 0x000000000000C071 
> (Lib:ReallocateRuntimePool) (VarCheckAddTableEntry() - 
> c:\home\edk-ii\mdemodulepkg\library\varchecklib\varchecklib.c:228)
> 0x00000001  0x0000000000000030 <== 0x0000000000002E08 (Lib:AllocateZeroPool) 
> (UpdateVariableInfo() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:196)
> 0x00000001  0x0000000000000044 <== 0x0000000000002E68 (Lib:AllocateZeroPool) 
> (UpdateVariableInfo() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:200)
> 0x0000002C  0x0000000000000840 <== 0x0000000000002F98 (Lib:AllocateZeroPool) 
> (UpdateVariableInfo() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:232)
> 0x0000002C  0x000000000000037C <== 0x0000000000002FF6 (Lib:AllocateZeroPool) 
> (UpdateVariableInfo() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:236)
> 0x00000001  0x000000000000000D <== 0x0000000000004DC9 
> (Lib:AllocateCopyRuntimePool) (AutoUpdateLangVariable() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:1960)
> 0x00000001  0x0000000000000012 <== 0x0000000000004CC4 
> (Lib:AllocateCopyRuntimePool) (AutoUpdateLangVariable() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:1930)
> 0x00000001  0x0000000000000012 <== 0x0000000000004D28 
> (Lib:AllocateRuntimePool) (AutoUpdateLangVariable() - 
> c:\home\edk-ii\mdemodulepkg\universal\variable\runtimedxe\variable.c:1940)
> 
> 

Are the address ranges allocated tracked? Is it possible to look up an address 
and figure out where it got allocated? 

Any plans to add logging for stalls? You can dump events with a debugger 
script, so that is not as important. 

Thanks,

Andrew Fish

> 
> 
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Andrew Fish
>> Sent: Thursday, June 30, 2016 2:38 PM
>> To: edk2-devel <edk2-devel@lists.01.org>
>> Subject: [edk2] Memory Profile question.
>> 
>> I've done some experimentation on the memory logging and if possible it is
>> very useful to have 4 stack frames (non-LTO)  as it is common for the
>> MemoryAllocationLib to to call a sequence of Internal functions, so to find
>> the calling spot in the driver you need 4 entries.
>> For example:
>> FunctionThatAllocatePool()
>> AllocateZeroPool()
>> InternalAllocateZeroPool()
>> InternalAllocatePool()
>> 
>> I see that only RETURN_ADDRESS (0) is logged.
>> 
>> MdeModulePkg/Core/Dxe/Mem/Page.c:1338:    CoreUpdateProfile
>> ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
>> MemoryProfileActionAllocatePages, MemoryType, EFI_PAGES_TO_SIZE
>> (NumberOfPages), (VOID *) (UINTN) *Memory);
>> MdeModulePkg/Core/Dxe/Mem/Page.c:1447:    CoreUpdateProfile
>> ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
>> MemoryProfileActionFreePages, MemoryType, EFI_PAGES_TO_SIZE
>> (NumberOfPages), (VOID *) (UINTN) Memory);
>> MdeModulePkg/Core/Dxe/Mem/Pool.c:279:    CoreUpdateProfile
>> ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
>> MemoryProfileActionAllocatePool, PoolType, Size, *Buffer);
>> MdeModulePkg/Core/Dxe/Mem/Pool.c:508:    CoreUpdateProfile
>> ((EFI_PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS (0),
>> MemoryProfileActionFreePool, PoolType, 0, Buffer);
>> 
>> On platforms that emit frame pointers you can do RETURN_ADDRESS (0),
>> RETURN_ADDRESS (1), RETURN_ADDRESS (2), and RETURN_ADDRESS (3)
>> and it is very useful to find the location of the allocation. Is it possible 
>> to log
>> more data on platforms that can support it? Is there some alternate scheme
>> that is planed to find the driver code calling the MemoryAllocationLib
>> function?
>> 
>> Thanks,
>> 
>> Andrew Fish
>> 
>> 
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to