From patchwork Tue Nov 17 11:45:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 104612 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.15767.1794915954037210414 for ; Tue, 17 Nov 2026 03:45:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=gmXfVE9r; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.47, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4bb61185057so20782185e9.1 for ; Tue, 17 Nov 2026 03:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1794915952; x=1795520752; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=4YTeCKI1vFObnOYKhg6m5upGXBqhtQnTUK3Z65y/ckA=; b=gmXfVE9rDjkYDXV0ywLNCZOWkUnfArYi/0jum4U+I/aHAtozYLyU+ckgpP+q3NkgGX 0H0rQIyCnZg81+i7TyjqQES/+Pvm9FFQRtsYIKbvHge4R74abbb+Gs1AMsLre0z/xTw5 RA42mMR0ZOdogIDZPzWMK6ohH970k35K/a7Go= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794915952; x=1795520752; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4YTeCKI1vFObnOYKhg6m5upGXBqhtQnTUK3Z65y/ckA=; b=FEruD2XIRdkcbkGs+t52T1qVUiumVOaHog1fDqW3JUQx8rkb9Qr8O8qiFnhiCx+0AA zn5U4q0SgRShteWbt2H6wd8zZ/kU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+B9pecvoHVHjdx epYo= X-Received: by 2002:a05:600c:6309:b0:4a2:5267:3cd4 with SMTP id 5b1f17b1804b1-4bb559f3bb9mr277695395e9.3.1794915951757; Tue, 17 Nov 2026 03:45:51 -0800 (PST) Return-Path: Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:5769:a004:a5af:24bf]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb7ad9426asm23650525e9.4.2026.11.17.03.45.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2026 03:45:51 -0800 (PST) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 1/2] runqueue: Improve deferred task sorting Date: Tue, 17 Nov 2026 11:45:48 +0000 Message-ID: <20261117114550.2306278-1-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Tue, 17 Nov 2026 11:45:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20445 Whilst looking for other problems, I noticed the sorting used for deferring tasks isn't always consistent. It needs to be so that same multiconfig is always preferred over the others, which gives a much lower chance of deadlocking. Add a helper sorting function and use it in all the locations we need this sorting. That means we can remove the weird looking looping code from the locations which did get this right. Signed-off-by: Richard Purdie --- lib/bb/runqueue.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py index 63615ac6c92..4f80f1fde21 100644 --- a/lib/bb/runqueue.py +++ b/lib/bb/runqueue.py @@ -85,6 +85,13 @@ def build_tid(mc, fn, taskname): return "mc:" + mc + ":" + fn + ":" + taskname return fn + ":" + taskname +def sort_tids_by_mc(tids, multiconfigs): + """ + Return tids grouped by multiconfig, with the groups in sorted mc order + and the tids sorted within each group. + """ + return [tid for _, tid in sorted(((mc_from_tid(tid), tid) for tid in tids))] + # Index used to pair up potentially matching multiconfig tasks # We match on PN, taskname and hash being equal def pending_hash_index(tid, rqdata): @@ -2109,7 +2116,7 @@ class RunQueueExecute: logger.debug("Marking task %s as buildable", revdep) found = None - for t in sorted(self.sq_deferred.copy()): + for t in sort_tids_by_mc(self.sq_deferred.copy(), self.sqdata.multiconfigs): if self.sq_deferred[t] == task: # Allow the next deferred task to run. Any other deferred tasks should be deferred after that task. # We shouldn't allow all to run at once as it is prone to races. @@ -2738,14 +2745,11 @@ class RunQueueExecute: if update_tasks2: self.sqdone = False - for mc in sorted(self.sqdata.multiconfigs): - for tid in sorted([t[0] for t in update_tasks2]): - if mc_from_tid(tid) != mc: - continue - h = pending_hash_index(tid, self.rqdata) - if h in self.sqdata.hashes and tid != self.sqdata.hashes[h]: - self.sq_deferred[tid] = self.sqdata.hashes[h] - bb.note("Deferring %s after %s" % (tid, self.sqdata.hashes[h])) + for tid in sort_tids_by_mc([t[0] for t in update_tasks2], self.sqdata.multiconfigs): + h = pending_hash_index(tid, self.rqdata) + if h in self.sqdata.hashes and tid != self.sqdata.hashes[h]: + self.sq_deferred[tid] = self.sqdata.hashes[h] + bb.note("Deferring %s after %s" % (tid, self.sqdata.hashes[h])) update_scenequeue_data([t[0] for t in update_tasks2], self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self, summary=False) for (tid, harddepfail, origvalid) in update_tasks2: @@ -3101,6 +3105,9 @@ def build_scenequeue_data(sqdata, rqdata, sqrq): if not sqdata.sq_revdeps[tid]: sqrq.sq_buildable.add(tid) + # Fix the ordering for determinism, sets are unordered + sqdata.multiconfigs = sorted(sqdata.multiconfigs) + rqdata.init_progress_reporter.next_stage() sqdata.noexec = set() @@ -3109,16 +3116,13 @@ def build_scenequeue_data(sqdata, rqdata, sqrq): sqdata.hashes = {} sqrq.sq_deferred = {} - for mc in sorted(sqdata.multiconfigs): - for tid in sorted(sqdata.sq_revdeps): - if mc_from_tid(tid) != mc: - continue - h = pending_hash_index(tid, rqdata) - if h not in sqdata.hashes: - sqdata.hashes[h] = tid - else: - sqrq.sq_deferred[tid] = sqdata.hashes[h] - bb.debug(1, "Deferring %s after %s" % (tid, sqdata.hashes[h])) + for tid in sort_tids_by_mc(sqdata.sq_revdeps, sqdata.multiconfigs): + h = pending_hash_index(tid, rqdata) + if h not in sqdata.hashes: + sqdata.hashes[h] = tid + else: + sqrq.sq_deferred[tid] = sqdata.hashes[h] + bb.debug(1, "Deferring %s after %s" % (tid, sqdata.hashes[h])) def check_setscene_stamps(tid, rqdata, rq, stampcache, noexecstamp=False):