Fix wrong CPU count after CPU hot-plugging
This fix tries to address issues raised in #23768 where the CPU count is not updated after cpu ho-plugging. This fix follows the suggestion from #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 #23768. This fix fixes #23768. The NumCPU() in Linux is based on @wmark 's implementation. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> Upstream-commit: 8b2383f5c1108c590928c0e6c57f1f0aa0dd36f6 Component: engine
This commit is contained in:
12
components/engine/pkg/sysinfo/numcpu.go
Normal file
12
components/engine/pkg/sysinfo/numcpu.go
Normal file
@ -0,0 +1,12 @@
|
||||
// +build !linux
|
||||
|
||||
package sysinfo
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// NumCPU returns the number of CPUs
|
||||
func NumCPU() int {
|
||||
return runtime.NumCPU()
|
||||
}
|
||||
Reference in New Issue
Block a user