summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2020-09-28 17:18:55 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-30 15:01:51 +0100
commitc2a11e18c8579a1352d35ffb5e1712810983c194 (patch)
tree57da538d1c28959735e7b6135a0c2775c9d6a72f /meta/lib
parent87ebed58c7cad06c82fac1e18f2a7a6ab2784c09 (diff)
downloadpoky-c2a11e18c8579a1352d35ffb5e1712810983c194.tar.gz
utils: respect scheduler affinity in cpu_count()
cpu_count() returns multiprocessing.cpu_count() but that is simply returns os.cpu_count() so we could use that directly. However this returns the number of CPUs on the host, not the number of usable CPUs on the host. If the user is using scheduler affinity then the number of usable CPUs may be less, so when determining how many cores we can use check the affinity instead. (From OE-Core rev: e2e8ccbe410b2f38bcd9525982b2261cf71aab60) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/utils.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 13f4271da0..468c76f30f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -249,8 +249,7 @@ def trim_version(version, num_parts=2):
249 return trimmed 249 return trimmed
250 250
251def cpu_count(at_least=1): 251def cpu_count(at_least=1):
252 import multiprocessing 252 cpus = len(os.sched_getaffinity(0))
253 cpus = multiprocessing.cpu_count()
254 return max(cpus, at_least) 253 return max(cpus, at_least)
255 254
256def execute_pre_post_process(d, cmds): 255def execute_pre_post_process(d, cmds):