path: root/meta/lib/oe/
diff options
authorRoss Burton <>2020-09-28 17:18:55 +0100
committerRichard Purdie <>2020-09-30 15:01:46 +0100
commite2e8ccbe410b2f38bcd9525982b2261cf71aab60 (patch)
tree316748ad85113e6e94d95840d6494211d90af4ed /meta/lib/oe/
parent6ba3e164d7afb69bddd546957331d0de7cb0a10b (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. Signed-off-by: Ross Burton <> Signed-off-by: Richard Purdie <>
Diffstat (limited to 'meta/lib/oe/')
1 files changed, 1 insertions, 2 deletions
diff --git a/meta/lib/oe/ b/meta/lib/oe/
index 13f4271da0..468c76f30f 100644
--- a/meta/lib/oe/
+++ b/meta/lib/oe/
@@ -249,8 +249,7 @@ def trim_version(version, num_parts=2):
return trimmed
def cpu_count(at_least=1):
- import multiprocessing
- cpus = multiprocessing.cpu_count()
+ cpus = len(os.sched_getaffinity(0))
return max(cpus, at_least)
def execute_pre_post_process(d, cmds):