From nobody Sun Jun 14 15:55:22 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 650C73A5E83; Fri, 3 Apr 2026 12:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775219429; cv=none; b=WUR3mubHYOOHZl4TwzFZvjMJxD2a528fuO4a4QGbPGHMmLeCH5DS4MRmowv2BS+A1ME4N+SyZVl0eQ7xSByn/FVg4a9hcUrx3Lay1UHN+PfaBxugV4uyWhhn+iNzRmaYp802uCwdXmUBpp/iiPPiRHOvmSdeDlXBrJBGLfs4Fbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775219429; c=relaxed/simple; bh=i5b0o1mx0oCfMGT9Udbcd9A+pLhg+MWa2lqWhTmEJnk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=a8jkFbpYRkwVj+6okZwTMF8EnO9zpYNePbrTXlorSmw6jUEFHt8vnZ4+yxRhHmKzX4XJxHqGIyM2OThAi/DGs2VBin2s/U7nz/zULZmEwavTPmcNBWZR73kcxYOontXapgWFpUlz1y12pxYMAV/PxuPS6LbpE0lWfBuhyIBvQjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WLGZEDlN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EtuzrjxX; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WLGZEDlN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EtuzrjxX" Date: Fri, 03 Apr 2026 12:30:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1775219427; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zzK75cc2ngclZoXRlEeOwPCZNKgkoWsTObxIFDuPLE=; b=WLGZEDlNgtwoBhtfTwQhZx5h6WXPwi2eUtcHhu79zO20bSJxBfg3JHKsMUjnyfn6Tp+cIw UpXfS/wy4XcqkL3oy6CFbgafd8frM7Qt6Nl0kNYxRDM19Yjp8v1oPK96+No4Ato4xcE5Np zEekbPiSvR1x/tuPbG1VQI95+qUMpbn5tzTW17vQv7cVbPw+NuqaLACwoaRgV8W/Xoz3GW /VjZPPCdcm5K3rL+zEqSACF1vgiysNwC4ltnJJZbCZetb4noznJRH+RLa1UGzGGMn5c4dX hBiwDvRLqpgRDU9onVGkcmUdmkRQvzXo75uKLyHq0Nhz4H3JG98+3Xwi401Miw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1775219427; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zzK75cc2ngclZoXRlEeOwPCZNKgkoWsTObxIFDuPLE=; b=EtuzrjxXxpKtgFczZtWgqN7A/nfVZFUhVBks3nyO3KZ1v7aS/wfAXwu8jpQ2zbe/7YA7AC SQdlejLbCZ1ZLfAw== From: "tip-bot2 for John Stultz" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Fix potentially missing balancing with Proxy Exec Cc: K Prateek Nayak , Peter Zijlstra , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260324191337.1841376-4-jstultz@google.com> References: <20260324191337.1841376-4-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177521942578.1647592.10167599243252186073.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: f4fe6be82e6d27349de66a42d6d1b2b11dc97a14 Gitweb: https://git.kernel.org/tip/f4fe6be82e6d27349de66a42d6d1b2b11= dc97a14 Author: John Stultz AuthorDate: Tue, 24 Mar 2026 19:13:18=20 Committer: Peter Zijlstra CommitterDate: Fri, 03 Apr 2026 14:23:39 +02:00 sched: Fix potentially missing balancing with Proxy Exec K Prateek pointed out that with Proxy Exec, we may have cases where we context switch in __schedule(), while the donor remains the same. This could cause balancing issues, since the put_prev_set_next() logic short-cuts if (prev =3D=3D next). With proxy-exec prev is the previous donor, and next is the next donor. Should the donor remain the same, but different tasks are picked to actually run, the shortcut will have avoided enqueuing the sched class balance callback. So, if we are context switching, add logic to catch the same-donor case, and trigger the put_prev/set_next calls to ensure the balance callbacks get enqueued. Closes: https://lore.kernel.org/lkml/20ea3670-c30a-433b-a07f-c4ff98ae2379@a= md.com/ Reported-by: K Prateek Nayak Suggested-by: Peter Zijlstra Signed-off-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260324191337.1841376-4-jstultz@google.com --- kernel/sched/core.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f3306d3..5b7f378 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6826,9 +6826,11 @@ static void __sched notrace __schedule(int sched_mod= e) =20 pick_again: next =3D pick_next_task(rq, rq->donor, &rf); - rq_set_donor(rq, next); rq->next_class =3D next->sched_class; if (sched_proxy_exec()) { + struct task_struct *prev_donor =3D rq->donor; + + rq_set_donor(rq, next); if (unlikely(next->blocked_on)) { next =3D find_proxy_task(rq, next, &rf); if (!next) @@ -6836,7 +6838,27 @@ pick_again: if (next =3D=3D rq->idle) goto keep_resched; } + if (rq->donor =3D=3D prev_donor && prev !=3D next) { + struct task_struct *donor =3D rq->donor; + /* + * When transitioning like: + * + * prev next + * donor: B B + * curr: A B or C + * + * then put_prev_set_next_task() will not have done + * anything, since B =3D=3D B. However, A might have + * missed a RT/DL balance opportunity due to being + * on_cpu. + */ + donor->sched_class->put_prev_task(rq, donor, donor); + donor->sched_class->set_next_task(rq, donor, true); + } + } else { + rq_set_donor(rq, next); } + picked: clear_tsk_need_resched(prev); clear_preempt_need_resched();