Skip to content
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

wrong CPU count after cpu hot-plugging #23768

Closed
mark-kubacki opened this issue Jun 20, 2016 · 3 comments · Fixed by #23955
Closed

wrong CPU count after cpu hot-plugging #23768

mark-kubacki opened this issue Jun 20, 2016 · 3 comments · Fixed by #23955
Labels
area/runtime kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Milestone

Comments

@mark-kubacki
Copy link

mark-kubacki commented Jun 20, 2016

Applies…

… to all Docker versions including 1.12.0-rc2.

Additional environment details (AWS, VirtualBox, physical, etc.):

metal

Steps to reproduce the issue:

  1. Start Docker. (Call docker info yourself or by Docker Swarm.)
  2. Insert or remove CPUs from the system, …
  3. … then observe docker info not displaying any changed values.

Without a hot-plugging–capable system you could (mask or) offline CPUs to reproduce this:

printf 0 >/sys/devices/system/cpu/cpu3/online

Describe the results you received:
Go's runtime.NumCPU is used, which gets its data from an initializer at the beginning of process lifetime. Any changes to CPU count do not get reflected by subsequent calls and return values of aforementioned function.

Describe the results you expected:
Docker should query the system itself. On Linux and using C you would utilize sysconf(_SC_NPROCESSORS_ONLN).

Additional information you deem important (e.g. issue happens only occasionally):
See also docker-archive/classicswarm#1949 and docker-archive/classicswarm#1992.

@thaJeztah thaJeztah added area/runtime kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Jun 20, 2016
@thaJeztah
Copy link
Member

ping @mlaventure

@yongtang
Copy link
Member

@wmark @thaJeztah @mlaventure I created a PR #23955 to try to address this one. Please let me know if there are any issues.

yongtang added a commit to yongtang/docker that referenced this issue Jun 26, 2016
This fix tries to address issues raised in moby#23768 where the CPU count
is not updated after cpu ho-plugging.

This fix follows the suggestion from moby#23768 and replace go's `runtime.NumCPU()`
with `sysconf(_SC_NPROCESSORS_ONLN)` so that correct CPU count could
be obtained even after CPU hot-plugging.

This fix is tested manually, as is suggested in moby#23768.

This fix fixes moby#23768.

The NumCPU() in Linux is based on @wmark 's implementation.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@mark-kubacki
Copy link
Author

Thanks to @dongluochen, @yongtang, @thaJeztah, @jhowardmsft, and @LK4D4 for fixing this!

@thaJeztah thaJeztah added this to the 1.13.0 milestone Jun 29, 2016
runcom pushed a commit to projectatomic/docker that referenced this issue Feb 26, 2017
Fix https://bugzilla.redhat.com/show_bug.cgi?id=1426788

This fix tries to address issues raised in moby#23768 where the CPU count
is not updated after cpu ho-plugging.

This fix follows the suggestion from moby#23768 and replace go's `runtime.NumCPU()`
with `sysconf(_SC_NPROCESSORS_ONLN)` so that correct CPU count could
be obtained even after CPU hot-plugging.

This fix is tested manually, as is suggested in moby#23768.

This fix fixes moby#23768.

The NumCPU() in Linux is based on @wmark 's implementation.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Revendor golang.org/x/sys/ to have unix package included.

This commit updates golang.org/x/sys/ in order to have needed unix
package included.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Fix wrong CPU count after CPU hot-plugging on Windows

This fix tries to fix wrong CPU count after CPU hot-plugging.
On windows, GetProcessAffinityMask has been used to probe the
number of CPUs in real time.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Fix s390x build failure by removing golang.org/x/sys

This fix tries to fix the issue raised in moby#24168 where
golang.org/x/sys causes s390x build failure.

This fix removed the import of "golang.org/x/sys/unix".

This fix fixes moby#24168.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Revendor golang.org/x/sys to remove golang.org/x/sys/unix

This fix tries to fix the issue raised in moby#24168 where
golang.org/x/sys causes s390x build failure.

This fix revendor golang.org/x/sys to removed the import
of "golang.org/x/sys/unix".

Note: The last commit removes the reference to
"golang.org/x/sys/unix".

This fix fixes moby#24168.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants