From 48682aff5d724f20195855ae694a0c8295522fa4 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 15:33:17 -0700 Subject: [PATCH 01/14] Logging. --- src/coreclr/gc/unix/gcenv.unix.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index b45cd40d8073fe..b1a1ae26419dbd 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -792,7 +792,7 @@ bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) return result; } -#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if (NEW_CACHE_SIZE > cacheSize) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } +#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != UINTMAX_MAX) || NEW_CACHE_SIZE > cacheSize) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } static size_t GetLogicalProcessorCacheSizeFromOS() { @@ -809,12 +809,16 @@ static size_t GetLogicalProcessorCacheSizeFromOS() UPDATE_CACHE_SIZE_AND_LEVEL(size, 2) #endif #ifdef _SC_LEVEL3_CACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL3_CACHE_SIZE); + size_t level3_dcache_size; + size = level3_dcache_size = ( size_t) sysconf(_SC_LEVEL3_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 3) + printf("[GetLogicalProcessorCacheSizeFromOS]: size after Level3DCacheSize (%zu): %zu\n", level3_dcache_size, size); #endif #ifdef _SC_LEVEL4_CACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE); + size_t level4_dcache_size; + size = level4_dcache_size = ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 4) + printf("[GetLogicalProcessorCacheSizeFromOS]: size after Level4DCacheSize (%zu): %zu\n", level4_dcache_size, size); #endif #if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86) From d4e7abc9eb54d1dfcfde17104cb3d226bfee3719 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 15:34:34 -0700 Subject: [PATCH 02/14] Fixed comparison check --- src/coreclr/gc/unix/gcenv.unix.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index b1a1ae26419dbd..9c1e9fea727ede 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -809,16 +809,12 @@ static size_t GetLogicalProcessorCacheSizeFromOS() UPDATE_CACHE_SIZE_AND_LEVEL(size, 2) #endif #ifdef _SC_LEVEL3_CACHE_SIZE - size_t level3_dcache_size; - size = level3_dcache_size = ( size_t) sysconf(_SC_LEVEL3_CACHE_SIZE); + size = ( size_t) sysconf(_SC_LEVEL3_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 3) - printf("[GetLogicalProcessorCacheSizeFromOS]: size after Level3DCacheSize (%zu): %zu\n", level3_dcache_size, size); #endif #ifdef _SC_LEVEL4_CACHE_SIZE - size_t level4_dcache_size; - size = level4_dcache_size = ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE); + size = ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 4) - printf("[GetLogicalProcessorCacheSizeFromOS]: size after Level4DCacheSize (%zu): %zu\n", level4_dcache_size, size); #endif #if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86) From 15beb1227c22e3b01b34635ad0074560c7ca3d63 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 15:39:25 -0700 Subject: [PATCH 03/14] Fix logical operations --- src/coreclr/gc/unix/gcenv.unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 9c1e9fea727ede..aa9bb2e01b4208 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -792,7 +792,7 @@ bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) return result; } -#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != UINTMAX_MAX) || NEW_CACHE_SIZE > cacheSize) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } +#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != UINTMAX_MAX) && (NEW_CACHE_SIZE > cacheSize)) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } static size_t GetLogicalProcessorCacheSizeFromOS() { From 0a7a08dadb008e3e0e3b37c49f24548463455e73 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 15:57:28 -0700 Subject: [PATCH 04/14] Completely guard against the cacheSize as UINTMAX_MAX --- src/coreclr/gc/unix/gcenv.unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index aa9bb2e01b4208..80a6e41ccd5e6f 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -818,7 +818,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86) - if (cacheSize == 0) + if (cacheSize == 0 || cacheSize == UINTMAX_MAX) { // // Fallback to retrieve cachesize via /sys/.. if sysconf was not available From 440ae97a087ccf335077d05f9fd5eeb058ee91c5 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 15:59:16 -0700 Subject: [PATCH 05/14] Fix for right macro --- src/coreclr/gc/unix/gcenv.unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 80a6e41ccd5e6f..bccb334b28f84c 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -792,7 +792,7 @@ bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) return result; } -#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != UINTMAX_MAX) && (NEW_CACHE_SIZE > cacheSize)) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } +#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != SIZE_MAX) && (NEW_CACHE_SIZE > cacheSize)) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } static size_t GetLogicalProcessorCacheSizeFromOS() { @@ -818,7 +818,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86) - if (cacheSize == 0 || cacheSize == UINTMAX_MAX) + if (cacheSize == 0 || cacheSize == SIZE_MAX) { // // Fallback to retrieve cachesize via /sys/.. if sysconf was not available From 6266af0043f7480bbd94c572c0a7fee6718d35a5 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Mon, 1 Apr 2024 16:02:03 -0700 Subject: [PATCH 06/14] Ensure we are guarded against all cases where cacheSize == SIZE_MAX --- src/coreclr/gc/unix/gcenv.unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index bccb334b28f84c..766525e039bea8 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -854,7 +854,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) - if (cacheSize == 0) + if (cacheSize == 0 || cacheSize == SIZE_MAX) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info // from most of the machines. @@ -882,7 +882,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if HAVE_SYSCTLBYNAME - if (cacheSize == 0) + if (cacheSize == 0 || cacheSize == SIZE_MAX) { int64_t cacheSizeFromSysctl = 0; size_t sz = sizeof(cacheSizeFromSysctl); From 3257f168cc6c946902094ec399a2ac7097287269 Mon Sep 17 00:00:00 2001 From: Mukund Raghav Sharma Date: Tue, 2 Apr 2024 00:44:40 -0700 Subject: [PATCH 07/14] Added an extra guard and removed redundant case --- src/coreclr/gc/unix/gcenv.unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 766525e039bea8..196b968bb7553d 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -818,7 +818,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86) - if (cacheSize == 0 || cacheSize == SIZE_MAX) + if (cacheSize == 0) { // // Fallback to retrieve cachesize via /sys/.. if sysconf was not available @@ -836,7 +836,8 @@ static size_t GetLogicalProcessorCacheSizeFromOS() { path_to_size_file[index] = (char)(48 + i); - if (ReadMemoryValueFromFile(path_to_size_file, &size)) + // Only accept reading cache sizes from size files if they are non-bogus values i.e., non-zero and != SIZE_MAX. + if (ReadMemoryValueFromFile(path_to_size_file, &size) && ((size != SIZE_MAX) || (size != 0))) { path_to_level_file[index] = (char)(48 + i); From 750632a2a0d13bbc71481ba25dbc5e41b415d718 Mon Sep 17 00:00:00 2001 From: Mukund Raghav Sharma Date: Tue, 2 Apr 2024 00:48:53 -0700 Subject: [PATCH 08/14] Comment clean --- src/coreclr/gc/unix/gcenv.unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 196b968bb7553d..59b8cbeb074778 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -836,7 +836,8 @@ static size_t GetLogicalProcessorCacheSizeFromOS() { path_to_size_file[index] = (char)(48 + i); - // Only accept reading cache sizes from size files if they are non-bogus values i.e., non-zero and != SIZE_MAX. + // Only accept reading cache sizes from size files if they are + // non-bogus values i.e., non-zero and != SIZE_MAX. if (ReadMemoryValueFromFile(path_to_size_file, &size) && ((size != SIZE_MAX) || (size != 0))) { path_to_level_file[index] = (char)(48 + i); From 5f787a52f248e12250313acdfb6c7d43234ce386 Mon Sep 17 00:00:00 2001 From: Mukund Raghav Sharma Date: Tue, 2 Apr 2024 01:30:00 -0700 Subject: [PATCH 09/14] Added some additional asserts --- src/coreclr/gc/unix/gcenv.unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 59b8cbeb074778..b09dea25607bdd 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -900,6 +900,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() if (success) { assert(cacheSizeFromSysctl > 0); + assert(cacheSizeFromSysctl != SIZE_MAX); cacheSize = ( size_t) cacheSizeFromSysctl; } } @@ -937,6 +938,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif + assert (cacheSize != SIZE_MAX); return cacheSize; } From 13e973b3bbbe9b072c2318d344891bbec7b4c30b Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 2 Apr 2024 12:29:52 -0700 Subject: [PATCH 10/14] Removed unnecessary checks for cacheSize == SIZE_MAX --- src/coreclr/gc/unix/gcenv.unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index b09dea25607bdd..ee5ba53458abb8 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -856,7 +856,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if (defined(HOST_ARM64) || defined(HOST_LOONGARCH64)) && !defined(TARGET_APPLE) - if (cacheSize == 0 || cacheSize == SIZE_MAX) + if (cacheSize == 0) { // We expect to get the L3 cache size for Arm64 but currently expected to be missing that info // from most of the machines. @@ -884,7 +884,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() #endif #if HAVE_SYSCTLBYNAME - if (cacheSize == 0 || cacheSize == SIZE_MAX) + if (cacheSize == 0) { int64_t cacheSizeFromSysctl = 0; size_t sz = sizeof(cacheSizeFromSysctl); From d162afea2d6d25c9998e7ad548950caabbafd300 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 2 Apr 2024 13:57:06 -0700 Subject: [PATCH 11/14] Cleaned up logic --- src/coreclr/gc/unix/gcenv.unix.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index ee5ba53458abb8..1953f87b34ecd6 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -792,28 +792,30 @@ bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) return result; } -#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if ((NEW_CACHE_SIZE != SIZE_MAX) && (NEW_CACHE_SIZE > cacheSize)) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } +#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if (NEW_CACHE_SIZE > cacheSize) { cacheSize = (size_t)NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } static size_t GetLogicalProcessorCacheSizeFromOS() { size_t cacheLevel = 0; size_t cacheSize = 0; - size_t size; + long size; + // sysconf can return -1 if the cache size is unavailable in some distros and 0 in others. + // UPDATE_CACHE_SIZE_AND_LEVEL should handle both the cases by not updating cacheSize if either of cases are met. #ifdef _SC_LEVEL1_DCACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL1_DCACHE_SIZE); + size = sysconf(_SC_LEVEL1_DCACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 1) #endif #ifdef _SC_LEVEL2_CACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL2_CACHE_SIZE); + size = sysconf(_SC_LEVEL2_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 2) #endif #ifdef _SC_LEVEL3_CACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL3_CACHE_SIZE); + size = sysconf(_SC_LEVEL3_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 3) #endif #ifdef _SC_LEVEL4_CACHE_SIZE - size = ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE); + size = sysconf(_SC_LEVEL4_CACHE_SIZE); UPDATE_CACHE_SIZE_AND_LEVEL(size, 4) #endif @@ -836,9 +838,12 @@ static size_t GetLogicalProcessorCacheSizeFromOS() { path_to_size_file[index] = (char)(48 + i); - // Only accept reading cache sizes from size files if they are - // non-bogus values i.e., non-zero and != SIZE_MAX. - if (ReadMemoryValueFromFile(path_to_size_file, &size) && ((size != SIZE_MAX) || (size != 0))) + uint64_t cache_size_from_sys_file = 0; + bool cache_size_read_from_sys_file_succeeded = ReadMemoryValueFromFile(path_to_size_file, &(cache_size_from_sys_file)); + size = (long)cache_size_from_sys_file; + + // This is a guard against the cache size value being -1. + if (cache_size_read_from_sys_file_succeeded && size > 0) { path_to_level_file[index] = (char)(48 + i); @@ -848,7 +853,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } else { - cacheSize = std::max(cacheSize, size); + cacheSize = std::max(cacheSize, ((size_t)size)); } } } @@ -900,7 +905,6 @@ static size_t GetLogicalProcessorCacheSizeFromOS() if (success) { assert(cacheSizeFromSysctl > 0); - assert(cacheSizeFromSysctl != SIZE_MAX); cacheSize = ( size_t) cacheSizeFromSysctl; } } @@ -938,7 +942,6 @@ static size_t GetLogicalProcessorCacheSizeFromOS() } #endif - assert (cacheSize != SIZE_MAX); return cacheSize; } From 65d763818eeb1724d1828c43d1821a05608044df Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 2 Apr 2024 14:54:45 -0700 Subject: [PATCH 12/14] Fix type casting comparison --- src/coreclr/gc/unix/gcenv.unix.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 1953f87b34ecd6..003f5ee17f5003 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -792,7 +792,7 @@ bool ReadMemoryValueFromFile(const char* filename, uint64_t* val) return result; } -#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if (NEW_CACHE_SIZE > cacheSize) { cacheSize = (size_t)NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } +#define UPDATE_CACHE_SIZE_AND_LEVEL(NEW_CACHE_SIZE, NEW_CACHE_LEVEL) if (NEW_CACHE_SIZE > ((long)cacheSize)) { cacheSize = NEW_CACHE_SIZE; cacheLevel = NEW_CACHE_LEVEL; } static size_t GetLogicalProcessorCacheSizeFromOS() { @@ -800,7 +800,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() size_t cacheSize = 0; long size; - // sysconf can return -1 if the cache size is unavailable in some distros and 0 in others. + // sysconf can return -1 if the cache size is unavailable in some distributions and 0 in others. // UPDATE_CACHE_SIZE_AND_LEVEL should handle both the cases by not updating cacheSize if either of cases are met. #ifdef _SC_LEVEL1_DCACHE_SIZE size = sysconf(_SC_LEVEL1_DCACHE_SIZE); @@ -839,21 +839,23 @@ static size_t GetLogicalProcessorCacheSizeFromOS() path_to_size_file[index] = (char)(48 + i); uint64_t cache_size_from_sys_file = 0; - bool cache_size_read_from_sys_file_succeeded = ReadMemoryValueFromFile(path_to_size_file, &(cache_size_from_sys_file)); - size = (long)cache_size_from_sys_file; - // This is a guard against the cache size value being -1. - if (cache_size_read_from_sys_file_succeeded && size > 0) + if (ReadMemoryValueFromFile(path_to_size_file, &cache_size_from_sys_file)) { + // uint64_t to long conversion as ReadMemoryValueFromFile takes a uint64_t* as an argument for the val argument. + size = (long)cache_size_from_sys_file; path_to_level_file[index] = (char)(48 + i); if (ReadMemoryValueFromFile(path_to_level_file, &level)) { UPDATE_CACHE_SIZE_AND_LEVEL(size, level) } - else + + // We guard against the case where the size = -1 or 0. + // This isn't currently an issue but to be safe, we add this check. + else if (size > 0) { - cacheSize = std::max(cacheSize, ((size_t)size)); + cacheSize = std::max((long)cacheSize, size); } } } From b3dec7e1626003191e552a04fc5cbbc504ab6fd5 Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 2 Apr 2024 17:03:07 -0700 Subject: [PATCH 13/14] Removed redundant comment --- src/coreclr/gc/unix/gcenv.unix.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 003f5ee17f5003..65a15217f4448b 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -851,8 +851,6 @@ static size_t GetLogicalProcessorCacheSizeFromOS() UPDATE_CACHE_SIZE_AND_LEVEL(size, level) } - // We guard against the case where the size = -1 or 0. - // This isn't currently an issue but to be safe, we add this check. else if (size > 0) { cacheSize = std::max((long)cacheSize, size); From 6efb2875acfbdd1f7a9c3ff191e2ce7ba0bf6d0e Mon Sep 17 00:00:00 2001 From: mrsharm Date: Tue, 2 Apr 2024 17:29:29 -0700 Subject: [PATCH 14/14] Removed one more unneccesary guard --- src/coreclr/gc/unix/gcenv.unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 65a15217f4448b..dd591a54426351 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -851,7 +851,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS() UPDATE_CACHE_SIZE_AND_LEVEL(size, level) } - else if (size > 0) + else { cacheSize = std::max((long)cacheSize, size); }