From nobody Mon Jun 8 07:24:44 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 E571C3C2784; Thu, 4 Jun 2026 18:45:26 +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=1780598728; cv=none; b=q1cQqHXGi37VpqVElGug3dfMsXj7Zf/Vfq9q9+OqnJ86DHMN5/o927g6jMOfkt0I7YLtacujpi0Lb/Vl3BqbeD3KCbJQAe2qTs+U0RChjI+K7eFkokvf7QLQyeqbrc8xacBcCmvelJA55XKMs9mBEw2x06SuIjdR89yj/b0xw+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780598728; c=relaxed/simple; bh=GyzmBEHchhdnbGEG0S30dio1vjkHXo6ul5VD6N1TrE8=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=qUM268dr5jPn3LowjjDNb3dTtev7Qv2n4aeSOFTrynfVZxJpFIjQkjJEZGYZEcwwE5aQVGE/ogoxuhyUlcIrrHId4F+27ElHqw7EtAUlWLrIpF9hT7FSu9itaTzVdnLzcL8xcunvfhNElRB4tKSFhezg82G7vM2H3YoZLgsFhD0= 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=fVVsTfhO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vjBnD7FB; 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="fVVsTfhO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vjBnD7FB" Date: Thu, 04 Jun 2026 18:45:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780598725; 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=Cr4rxKiTY6sRAozkhGUJ3BK7H8Su0Clqcd3jHQmWGT0=; b=fVVsTfhO+OT81Qm1dBiADYC1yolWB8azy6yVuXCGR1Pmy5feYFK/sNPIArJA+I0T0QDVbl l018osblzrrVkLkvJMNApHGTvzS/8V16YpdLulg1BX/HAaIvOH/hdZtQkSrIEFlwDRD9S3 Ig+NUXOdpSD6DjUXqaZzNF4rZKHU1gtZHF/h9MVznJ4N1wQa9jeBzhjWbg7ts4qTkJXh7Z gMnTg7p9xgBx0CZP8R4mC6v9JPraYhAS/X2FJhK0jFcPJU/iIr2wGbsHf9LiMxKcYNbSNn haw9NLzqpDnlgBVVD7r+jjQ+8YAdqNrJ5ggH4N5Cui54lzZ/rWn26Ue/8NVOhQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780598725; 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=Cr4rxKiTY6sRAozkhGUJ3BK7H8Su0Clqcd3jHQmWGT0=; b=vjBnD7FBp0Istng9YQodiH3v/G/ehikrR/ONsF93Oz5Om2dDx8st8BIQxhkgFaG6hYtFg5 3nwi06eJgsIvM7Ag== 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: Call update_curr() before unthrottling the hierarchy Cc: K Prateek Nayak , "Peter Zijlstra (Intel)" , Benjamin Segall , Aaron Lu , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260602052531.11450-1-kprateek.nayak@amd.com> References: <20260602052531.11450-1-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: <178059872401.710.9177755690246877350.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: 28ad5427682bccf06074366f347a6083d6730c1e Gitweb: https://git.kernel.org/tip/28ad5427682bccf06074366f347a6083d= 6730c1e Author: K Prateek Nayak AuthorDate: Tue, 02 Jun 2026 05:25:29=20 Committer: Peter Zijlstra CommitterDate: Tue, 02 Jun 2026 12:26:12 +02:00 sched/fair: Call update_curr() before unthrottling the hierarchy Subsequent commits will allow update_curr() to throttle the hierarchy when the runtime accounting exceeds allocated quota. Call update_curr() before the unthrottle event, and in tg_unthrottle_up() to catch up on any remaining runtime and stabilize the "runtime_remaining" and "throttle_count" for that cfs_rq. Doing an update_curr() early ensures the cfs_rq is not throttled right back up again when the unthrottle is in progress. Since all callers of unthrottle_cfs_rq(), except two, already update the rq_clock and call rq_clock_start_loop_update(), move the update_rq_clock() from unthrottle_cfs_rq() to the callers that don't update the rq_clock. 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-1-kprateek.nayak@amd.com --- kernel/sched/core.c | 5 ++++- kernel/sched/fair.c | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index dd03141..e745c58 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9859,11 +9859,14 @@ static int tg_set_cfs_bandwidth(struct task_group *= tg, struct rq *rq =3D cfs_rq->rq; =20 guard(rq_lock_irq)(rq); + cfs_rq->runtime_enabled =3D runtime_enabled; cfs_rq->runtime_remaining =3D 1; =20 - if (cfs_rq->throttled) + if (cfs_rq->throttled) { + update_rq_clock(rq); unthrottle_cfs_rq(cfs_rq); + } } =20 if (runtime_was_enabled && !runtime_enabled) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 26a8bbb..f91d85c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6740,6 +6740,15 @@ static int tg_unthrottle_up(struct task_group *tg, v= oid *data) struct cfs_rq *cfs_rq =3D tg_cfs_rq(tg, cpu_of(rq)); struct task_struct *p, *tmp; =20 + /* + * If cfs_rq->curr is set, the cfs_rq might not have caught up + * since the last clock update. Do it now before we begin + * queueing task onto it to save the need for unnecessarily + * unthrottle the hierarchy for this cfs_rq to be throttled + * right back again. + */ + update_curr(cfs_rq); + if (--cfs_rq->throttle_count) return 0; =20 @@ -6882,14 +6891,16 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) * We can't unthrottle this cfs_rq without any runtime remaining because * any enqueue in tg_unthrottle_up() will immediately trigger a throttle, * which is not supposed to happen on unthrottle path. + * + * Catch up on the remaining runtime since last clock update before + * checking runtime remaining. */ + update_curr(cfs_rq); if (cfs_rq->runtime_enabled && cfs_rq->runtime_remaining <=3D 0) return; =20 cfs_rq->throttled =3D 0; =20 - update_rq_clock(rq); - scoped_guard(raw_spinlock, &cfs_b->lock) { list_del_rcu(&cfs_rq->throttled_list); =20 @@ -6964,6 +6975,7 @@ static inline void __unthrottle_cfs_rq_async(struct c= fs_rq *cfs_rq) bool first; =20 if (rq =3D=3D this_rq()) { + update_rq_clock(rq); unthrottle_cfs_rq(cfs_rq); return; } @@ -7017,6 +7029,11 @@ static bool distribute_cfs_runtime(struct cfs_bandwi= dth *cfs_b) if (!list_empty(&cfs_rq->throttled_csd_list)) continue; =20 + if (cfs_rq->curr) { + update_rq_clock(rq); + update_curr(cfs_rq); + } + /* By the above checks, this should never be true */ WARN_ON_ONCE(cfs_rq->runtime_remaining > 0); =20