-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly detect CPU cores when cpuset cgroup is used #5373
Conversation
@davidpanderson, could you please review this improvement? |
For the record the origin is from |
@AenBleidd: __GNU_LIBRARY__ is not defined on the Mac, so the added code has no effect. The Mac has no sched_getaffinity() function, but a quick Google search came up with this as a possible workaround. I am not familiar with the concept of cgroup cpusets or CPU affinity, but I am puzzled by the implementation in this PR because the file client/hostinfor_unix.cpp is used only in the client, and not in any BOINC libraries. So I suspect the code guarded by
So this code will only return information for the client process itself. It's unclear to me whether this is what @CallMeFoxie intended. |
I was mostly worried that this code might break some functionality on MacOS. If it will have no effect - that is perfectly fine.
This is completely fine. I have doubts anyone uses
I believe, the intention is to limit CPU usage of BOINC using native linux tools (for whatever reasons). |
I think it is working correctly? Because after the patch I can do
yet the original method was returning all 56 cores as lscpu does:
|
Basically the whole idea is that BOINC sees the actual assigned cpu core count, not the whole machine, because if it runs in some container it may have some limits imposed (be it docker or just general cgroups limits outside of any container) |
Sorry to pick nits, but please use 4-space indentation and space in 'if ('. |
4154f30
to
90838f6
Compare
@CallMeFoxie, thank you for this fix! |
Description of the Change
CPU cores are not correctly detected when eg running within a container that uses cgroup cpusets. This change should improve the detection. I am not 100% sure about other platforms and may need some ifdefing, but I do not have many platforms to test it on.
Alternate Designs
this code was checked against
nproc
which uses the same methodRelease Notes
Detect CPU cores when using cpuset to limit core count