[edk2-devel] [PATCH v5 4/4] UefiCpuPkg/CpuCacheInfoLib: Add QuickSort function on BaseLib
Marvin Häuser
mhaeuser at posteo.de
Mon Oct 4 12:59:14 UTC 2021
Good day IanX,
On 04/10/2021 07:03, IanX Kuo wrote:
> From: IanX Kuo <ianx.kuo at intel.com>
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3675
>
> Remove MdeModulePkg dependency
>
> Cc: Eric Dong <eric.dong at intel.com>
> Cc: Ray Ni <ray.ni at intel.com>
> Cc: Rahul Kumar <rahul1.kumar at intel.com>
> Signed-off-by: IanX Kuo <ianx.kuo at intel.com>
> ---
> UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c | 5 ++++-
> UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf | 2 --
> UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h | 2 --
> UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf | 2 --
> 4 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c b/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
> index c0077d6770..b5ed05bd43 100644
> --- a/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
> +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/CpuCacheInfoLib.c
> @@ -282,6 +282,7 @@ CpuCacheInfoCollectCpuCacheInfoData (
> UINTN LocalCacheInfoCount;
> UINTN Index;
> UINTN NextIndex;
> + VOID *QuickSortBuffer;
>
> //
> // Get number of Packages and Package ID.
> @@ -369,7 +370,9 @@ CpuCacheInfoCollectCpuCacheInfoData (
> //
> // Sort LocalCacheInfo array by CPU package ID, core type, cache level and cache type.
> //
> - PerformQuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInfo), (SORT_COMPARE) CpuCacheInfoCompare);
> + QuickSortBuffer = AllocateZeroPool (sizeof (*LocalCacheInfo));
CPU_CACHE_INFO is just a couple Bytes in size, maybe just allocate it on
the stack?
> + ASSERT (QuickSortBuffer != NULL);
Please handle memory allocation failures properly.
Best regards,
Marvin
> + QuickSort (LocalCacheInfo, LocalCacheInfoCount, sizeof (*LocalCacheInfo), (BASE_SORT_COMPARE) CpuCacheInfoCompare, QuickSortBuffer);
> CopyMem (CacheInfo, LocalCacheInfo, sizeof (*CacheInfo) * LocalCacheInfoCount);
> DEBUG_CODE (
> CpuCacheInfoPrintCpuCacheInfoTable (CacheInfo, LocalCacheInfoCount);
> diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf b/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf
> index c3d3f1e799..fdd79970f9 100644
> --- a/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf
> +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/DxeCpuCacheInfoLib.inf
> @@ -25,7 +25,6 @@
>
> [Packages]
> MdePkg/MdePkg.dec
> - MdeModulePkg/MdeModulePkg.dec
> UefiCpuPkg/UefiCpuPkg.dec
>
> [LibraryClasses]
> @@ -34,7 +33,6 @@
> BaseMemoryLib
> MemoryAllocationLib
> UefiBootServicesTableLib
> - SortLib
>
> [Protocols]
> gEfiMpServiceProtocolGuid
> diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h b/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h
> index 26e1f46516..af60588e34 100644
> --- a/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h
> +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/InternalCpuCacheInfoLib.h
> @@ -13,11 +13,9 @@
> #include <Register/Cpuid.h>
> #include <Ppi/MpServices2.h>
> #include <Protocol/MpService.h>
> -#include <Library/BaseLib.h>
> #include <Library/DebugLib.h>
> #include <Library/BaseMemoryLib.h>
> #include <Library/MemoryAllocationLib.h>
> -#include <Library/SortLib.h>
> #include <Library/CpuCacheInfoLib.h>
>
> typedef union {
> diff --git a/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf b/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf
> index 0864497849..c643fc89be 100644
> --- a/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf
> +++ b/UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.inf
> @@ -25,7 +25,6 @@
>
> [Packages]
> MdePkg/MdePkg.dec
> - MdeModulePkg/MdeModulePkg.dec
> UefiCpuPkg/UefiCpuPkg.dec
>
> [LibraryClasses]
> @@ -34,7 +33,6 @@
> BaseMemoryLib
> MemoryAllocationLib
> PeiServicesTablePointerLib
> - SortLib
>
> [Ppis]
> gEdkiiPeiMpServices2PpiGuid
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81449): https://edk2.groups.io/g/devel/message/81449
Mute This Topic: https://groups.io/mt/86059873/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list