Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c43d033

Browse files
authored
Revert CPU clipping in the presence of CPU quota to 3.0, 2.x behavior.
Basically reverting #26806
1 parent 2f99ca8 commit c43d033

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/classlibnative/bcltype/system.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ INT32 QCALLTYPE SystemNative::GetProcessorCount()
352352
processorCount = systemInfo.dwNumberOfProcessors;
353353
}
354354

355+
#ifdef FEATURE_PAL
356+
uint32_t cpuLimit;
357+
358+
if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < (uint32_t)processorCount)
359+
processorCount = cpuLimit;
360+
#endif
361+
355362
END_QCALL;
356363

357364
return processorCount;

src/pal/src/thread/process.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,6 +2558,12 @@ PAL_GetCPUBusyTime(
25582558
{
25592559
return 0;
25602560
}
2561+
2562+
UINT cpuLimit;
2563+
if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < dwNumberOfProcessors)
2564+
{
2565+
dwNumberOfProcessors = cpuLimit;
2566+
}
25612567
}
25622568

25632569
if (getrusage(RUSAGE_SELF, &resUsage) == -1)

src/utilcode/util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,10 @@ int GetCurrentProcessCpuCount()
12891289

12901290
#else // !FEATURE_PAL
12911291
count = PAL_GetLogicalCpuCountFromOS();
1292+
1293+
uint32_t cpuLimit;
1294+
if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < count)
1295+
count = cpuLimit;
12921296
#endif // !FEATURE_PAL
12931297

12941298
cCPUs = count;

0 commit comments

Comments
 (0)