From nobody Mon Jun 8 07:24:00 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 A07743C09EA; Thu, 4 Jun 2026 18:45:25 +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=1780598727; cv=none; b=FlO+Wi7uIob2LDcS/4pSnX7GV1oMBMqU7K+IkHR9OXIyHavrVKXruIvWz00/xrhzMNCA2/q3ENciiOLyO4DTkA1bLlZnvCdcWIRcot9pOtJ4J2B5Gy0HTJPZRhdDIuhRuZXCPCowD7hdd8u1FVfTap/kGZX4HGZ3+vMQKVGePNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598727; c=relaxed/simple; bh=t3nbBhfvknM2j7Mw3R5bqOQCIKKMDzA5l9iiJsxWf0M=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=HRpwOc6Np6NMGx0SXfjOPzkbXdY7fWI0CVkYHkouEi4nUgrrcvSwQTEYE5Qdyr/WWoHGYUD2fSfqCta2qIvwbQAPHs3zqKA2E/7+Huk6D0aV8ukwBdo748uPZ1TES+wnRw9CUOEMLgtyH6/HLEyBiSu9isqNp4GeKwphv/o86C8= 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=Rho/c1PL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dl9TGigK; 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="Rho/c1PL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dl9TGigK" Date: Thu, 04 Jun 2026 18:45:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780598724; 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=/nSocCA8+yUqNcumy8DR6m9yp+wmUAhkSe0xYkhFydg=; b=Rho/c1PLSya4+ZPK5IQ57YW3uNkepUv8jIFvFAHTgieJ8OaEu90TARvhgpUVQTwL0oRYhj ZGScunXJITrZI3jaAXxOYyimpSAOPWOEU34CL2E/XN2R/XBOwOhtABx8aFHc3AMx3T0Sd8 JftuvAzpNmzKD04FP5Q33lxdlBSmrjOV2o6pLbhmE+crZnUoESEb/m8aLwsUIf14cMieTU 3vukZPFCjpH7e1SvG71YICtbkOwy/P3BhW6acUfQdWSK+wKv55LdmFER0fBIys7jhCDlKR GBr2AlVLCrSnV+Dff7CXjdB12JLhBxYu2SPA2HHy8O1hxGivJWn4E5yfNFkeoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780598724; 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=/nSocCA8+yUqNcumy8DR6m9yp+wmUAhkSe0xYkhFydg=; b=dl9TGigKvhmtVC3oR3BSZXpbyD6poMLtvjbhMA1O0ac8ClMUg1aJFbnbHDezTk21iLekUp 5bUY5ZP83rdT39CA== From: "tip-bot2 for K Prateek Nayak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Move the throttled tasks to a local list in tg_unthrottle_up() Cc: K Prateek Nayak , "Peter Zijlstra (Intel)" , Benjamin Segall , Aaron Lu , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260602052531.11450-2-kprateek.nayak@amd.com> References: <20260602052531.11450-2-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178059872259.710.12109510442808012575.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: 102a28344a60e637934ffca62d50ff8319b11165 Gitweb: https://git.kernel.org/tip/102a28344a60e637934ffca62d50ff831= 9b11165 Author: K Prateek Nayak AuthorDate: Tue, 02 Jun 2026 05:25:30=20 Committer: Peter Zijlstra CommitterDate: Tue, 02 Jun 2026 12:26:12 +02:00 sched/fair: Move the throttled tasks to a local list in tg_unthrottle_up() An update_curr() during the enqueue of throttled task will start throttling the hierarchy from subsequent commit. This can lead to tg_throttle_down() seeing non-empty throttled_limbo_list for the cfs_rq attaching the task from throttled_limbo_list one by one. For example: R | A / \ *B C | rq->curr *B is throttled with tasks on hte limbo list. When the tasks are unthrottled via tg_unthrottle_up() and entity of group B is placed onto A, update_curr() is called to catch up the vruntime and it may throttle group A causing the subsequent tg_throttle_down() to see the pending task's on B's limbo list. tg_unthrottle_up() /* --cfs_rq->throttle_count =3D=3D 0 */ list_for_each_entry_safe(p, cfs_rq->throttled_limbo_list) enqueue_task_fair() enqueue_entity(se /* B->se */) update_curr(cfs_rq /* A->gcfs_rq */) account_cfs_rq_runtime(cfs_rq) throttle_cfs_rq(cfs_rq /* A->gcfs_rq */ ) tg_throttle_down() /* Reaches B->cfs_rq with throttle_count =3D=3D 0 */ !!! !list_empty(&cfs_rq->throttled_limbo_list)) !!! Move the tasks from throttled_limbo_list onto a local list before starting the unthrottle to prevent the splat described above. If the hierarchy is throttled again in middle of an unthrottle, put the pending tasks back onto the limbo list to prevent running them unnecessarily. Signed-off-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Benjamin Segall Tested-by: Aaron Lu Link: https://patch.msgid.link/20260602052531.11450-2-kprateek.nayak@amd.com --- kernel/sched/fair.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index f91d85c..3f3f09a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6739,6 +6739,7 @@ static int tg_unthrottle_up(struct task_group *tg, vo= id *data) struct rq *rq =3D data; struct cfs_rq *cfs_rq =3D tg_cfs_rq(tg, cpu_of(rq)); struct task_struct *p, *tmp; + LIST_HEAD(throttled_tasks); =20 /* * If cfs_rq->curr is set, the cfs_rq might not have caught up @@ -6769,13 +6770,31 @@ static int tg_unthrottle_up(struct task_group *tg, = void *data) cfs_rq->throttled_clock_self_time +=3D delta; } =20 + /* + * Move the tasks to a local list since an update_curr() during + * enqueue_task_fair() can throttle a higher cfs_rq, and it can + * see the "throttled_limbo_list" being non-empty in + * tg_throttle_down() if throttle_count turned 0 above. + */ + list_splice_init(&cfs_rq->throttled_limbo_list, &throttled_tasks); + /* Re-enqueue the tasks that have been throttled at this level. */ - list_for_each_entry_safe(p, tmp, &cfs_rq->throttled_limbo_list, throttle_= node) { + list_for_each_entry_safe(p, tmp, &throttled_tasks, throttle_node) { + /* + * Back to being throttled! Break out and put the remaining + * tasks back onto the limbo_list to prevent running them + * unnecessarily. + */ + if (cfs_rq->throttle_count) + break; + list_del_init(&p->throttle_node); p->throttled =3D false; - enqueue_task_fair(rq_of(cfs_rq), p, ENQUEUE_WAKEUP); + enqueue_task_fair(rq, p, ENQUEUE_WAKEUP); } =20 + list_splice(&throttled_tasks, &cfs_rq->throttled_limbo_list); + /* Add cfs_rq with load or one or more already running entities to the li= st */ if (!cfs_rq_is_decayed(cfs_rq)) list_add_leaf_cfs_rq(cfs_rq);