path: root/meta
diff options
authorRoss Burton <>2020-09-28 16:18:55 (GMT)
committerRichard Purdie <>2020-09-30 14:01:51 (GMT)
commitc2a11e18c8579a1352d35ffb5e1712810983c194 (patch)
tree57da538d1c28959735e7b6135a0c2775c9d6a72f /meta
parent87ebed58c7cad06c82fac1e18f2a7a6ab2784c09 (diff)
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 <> Signed-off-by: Richard Purdie <>
Diffstat (limited to 'meta')
1 files changed, 1 insertions, 2 deletions
diff --git a/meta/lib/oe/ b/meta/lib/oe/
index 13f4271..468c76f 100644
--- a/meta/lib/oe/
+++ b/meta/lib/oe/
@@ -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):