Skip to content

Commit 9b10c53

Browse files
Fix querying L3 cache size on osx-x64 (#75870)
Co-authored-by: Filip Navara <navara@emclient.com>
1 parent 3056135 commit 9b10c53

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/coreclr/gc/unix/gcenv.unix.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,11 @@ static size_t GetLogicalProcessorCacheSizeFromOS()
968968
int64_t cacheSizeFromSysctl = 0;
969969
size_t sz = sizeof(cacheSizeFromSysctl);
970970
const bool success = false
971-
// macOS-arm64: Since macOS 12.0, Apple added ".perflevelX." to determinate cache sizes for efficiency
971+
// macOS: Since macOS 12.0, Apple added ".perflevelX." to determinate cache sizes for efficiency
972972
// and performance cores separately. "perflevel0" stands for "performance"
973+
|| sysctlbyname("hw.perflevel0.l3cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
973974
|| sysctlbyname("hw.perflevel0.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
974-
// macOS-arm64: these report cache sizes for efficiency cores only:
975+
// macOS: these report cache sizes for efficiency cores only:
975976
|| sysctlbyname("hw.l3cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
976977
|| sysctlbyname("hw.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
977978
|| sysctlbyname("hw.l1dcachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0;

src/coreclr/pal/src/misc/sysinfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,11 @@ PAL_GetLogicalProcessorCacheSizeFromOS()
636636
int64_t cacheSizeFromSysctl = 0;
637637
size_t sz = sizeof(cacheSizeFromSysctl);
638638
const bool success = false
639-
// macOS-arm64: Since macOS 12.0, Apple added ".perflevelX." to determinate cache sizes for efficiency
639+
// macOS: Since macOS 12.0, Apple added ".perflevelX." to determinate cache sizes for efficiency
640640
// and performance cores separately. "perflevel0" stands for "performance"
641+
|| sysctlbyname("hw.perflevel0.l3cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
641642
|| sysctlbyname("hw.perflevel0.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
642-
// macOS-arm64: these report cache sizes for efficiency cores only:
643+
// macOS: these report cache sizes for efficiency cores only:
643644
|| sysctlbyname("hw.l3cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
644645
|| sysctlbyname("hw.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
645646
|| sysctlbyname("hw.l1dcachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0;

0 commit comments

Comments
 (0)