Mike,
Thanks for your comment. I have additional comment for current design.

I know there is a requirement for UEFI S4 resume that need to have consistent 
memory map and OS using gBS->GetMemoryMap() for such check.
CoreGetMemoryMap returned UEFI memory map based on the information conveyed via 
gMemoryTypeInformation[] which is the same pointer DXE core installs into 
ConfigurationTable.

Yes, from current implement, it logs only peak usage but I am curious about why 
it should not reflect the real usage for current boot. (Differ to what EDK 
version had implemented.)
If we look from current UEFI memory management, PEI phase use either existing 
UEFI variable or predefined configuration to create 
gEfiMemoryTypeInformationGuid GUIDed Hob. DXE Core uses this HOB during 
CoreInitializeMemoryServices() for pre-allocate memory bins for different type 
of memory. Platform design might choose to handle estimated BIN size does not 
fit to current memory usage we get from mMemoryTypeStatistics[] via (1) Update 
MemoryTypeInformation UEFI variable and (2) Triggers a platform reset for 
adjusting bin size in the next boot path which accommodate real memory usage 
model.

If there is a DXE driver which allocates a memory band for tentative 
operational use and finally get freed when done, current implement will not 
reflect this change to gMemoryTypeInformation[] that mismatch to 
mMemoryTypeStatistics[] and the bin adjustment process performed that caused we 
pre-allocate bigger bin size that real active components are using. It will not 
hurt anything but will it better we even don’t need to do the additional bin 
adjustment if the gMemoryTypeInformation[] always been updated to match real 
memory usage? In this way, we get a more compact memory map and not leaving 
available memory band at the end of each memory bin.

Thanks,
- Mars

寄件者: Kinney, Michael D [mailto:[email protected]]
寄件日期: 2014年7月15日 上午 05:41
收件者: [email protected]
主旨: Re: [edk2] Memory usage does not get updated when free the allocated one

Mars Lin,

The purpose of the gEfiMemoryTypeInformationGuid system configuration table is 
to track the peak usage of each memory type.  Not the current usage.  The 
internal data structure mMemoryTypeStatistics tracks the current usage of each 
memory type.

We need to know the peak usage of each memory type so the size of each memory 
type bin can be set to guarantee that all the allocations during an entire boot 
can fit within that bin.

I think your proposed change could produce a bin size that is smaller than the 
peak, which could result in S4 resume failures for some operating systems.

Do you agree?

Thanks,

Mike



From: Mars Lin [mailto:[email protected]]
Sent: Monday, July 14, 2014 3:04 AM
To: [email protected]<mailto:[email protected]>
Subject: [edk2] Memory usage does not get updated when free the allocated one

Dear MdeModulePkg maintainer,
Please review attached patch file which try to correct the MemoryTypeInfo does 
not get updated within CoreConvertPages().

Steps to reproduce:
0. EfiLibGetSystemConfigurationTable (&gEfiMemoryTypeInformationGuid, 
&CurrentMemoryTypeInformation1)
1. AllocatePool (EfiBootServicesData, 0x80000, &BsData);
2. EfiLibGetSystemConfigurationTable (&gEfiMemoryTypeInformationGuid, 
&CurrentMemoryTypeInformation2)
3. FreePool (BsData)
4. EfiLibGetSystemConfigurationTable (&gEfiMemoryTypeInformationGuid, & 
CurrentMemoryTypeInformation3)

#1. CurrentMemoryTypeInformation2 get updated with EfiBootServicesData type 
grow 128 pages compare to CurrentMemoryTypeInformation1==> Correct!
#2. CurrentMemoryTypeInformation3 does not get updated with EfiBootServicesData 
type reduced 128 pages compare to CurrentMemoryTypeInformation2==> Problem!
----------------------------------------------------------------------------------------------------------------------
MdeModulePkg: Memory usage does not get updated when free the allocated one

Update gMemoryTypeInfo array when specific memory type been freed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Smith Cheng 
<[email protected]<mailto:[email protected]>>
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to