summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Moessbauer <felix.moessbauer@siemens.com>2024-03-13 11:06:45 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-22 16:26:45 +0000
commit9504df41f9e1c64014436a46abf058c5d3f42d3f (patch)
tree559b4e1085898cdf6fe44fc690318ecc806f2a4b
parent3a97792820935392a1adfddc3abbef7d741f6b98 (diff)
downloadpoky-9504df41f9e1c64014436a46abf058c5d3f42d3f.tar.gz
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>
-rw-r--r--bitbake/lib/bb/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index ad13d04331..ebee65d3dd 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1142,7 +1142,10 @@ def get_referenced_vars(start_expr, d):
1142 1142
1143 1143
1144def cpu_count(): 1144def cpu_count():
1145 return multiprocessing.cpu_count() 1145 try:
1146 return len(os.sched_getaffinity(0))
1147 except OSError:
1148 return multiprocessing.cpu_count()
1146 1149
1147def nonblockingfd(fd): 1150def nonblockingfd(fd):
1148 fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK) 1151 fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)