Revert CPU clipping in the presence of CPU quota to 3.0, 2.x behavior.
authorVladimir Sadov <vsadov@microsoft.com>
Wed, 15 Jan 2020 03:31:01 +0000 (19:31 -0800)
committerGitHub <noreply@github.com>
Wed, 15 Jan 2020 03:31:01 +0000 (19:31 -0800)
Basically reverting https://github.com/dotnet/coreclr/pull/26806

src/classlibnative/bcltype/system.cpp
src/pal/src/thread/process.cpp
src/utilcode/util.cpp

index 402a215..e38f7db 100644 (file)
@@ -352,6 +352,13 @@ INT32 QCALLTYPE SystemNative::GetProcessorCount()
         processorCount = systemInfo.dwNumberOfProcessors;
     }
 
+#ifdef FEATURE_PAL     
+    uint32_t cpuLimit; 
+
+    if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < (uint32_t)processorCount)     
+        processorCount = cpuLimit;     
+#endif
+
     END_QCALL;
 
     return processorCount;
index 4f9d318..4b77f63 100644 (file)
@@ -2558,6 +2558,12 @@ PAL_GetCPUBusyTime(
         {
             return 0;
         }
+
+        UINT cpuLimit; 
+        if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < dwNumberOfProcessors)     
+        {      
+            dwNumberOfProcessors = cpuLimit;   
+        }
     }
 
     if (getrusage(RUSAGE_SELF, &resUsage) == -1)
index e0f0200..5c35b1a 100644 (file)
@@ -1289,6 +1289,10 @@ int GetCurrentProcessCpuCount()
 
 #else // !FEATURE_PAL
     count = PAL_GetLogicalCpuCountFromOS();
+
+    uint32_t cpuLimit; 
+    if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < count)        
+        count = cpuLimit;      
 #endif // !FEATURE_PAL
 
     cCPUs = count;