mirror of
https://git.yoctoproject.org/git/poky
synced 2026-01-04 16:10:04 +00:00
bitbake: utils: better estimate number of available cpus
When running in a cgroup which is limited to a subset of cpus (via cpuset.cpus), cpu_count() should return the number of cpus that can be used instead of the number of cpus the system has. This also aligns the semantics with nproc. (Bitbake rev: a029bfe96c6542f178720c72a772b7ede9898118) Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
3a97792820
commit
9504df41f9
|
|
@ -1142,7 +1142,10 @@ def get_referenced_vars(start_expr, d):
|
|||
|
||||
|
||||
def cpu_count():
|
||||
return multiprocessing.cpu_count()
|
||||
try:
|
||||
return len(os.sched_getaffinity(0))
|
||||
except OSError:
|
||||
return multiprocessing.cpu_count()
|
||||
|
||||
def nonblockingfd(fd):
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user