mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for K Prateek Nayak" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: K Prateek Nayak <kprateek.nayak@amd.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Benjamin Segall <bsegall@google.com>,
	Aaron Lu <ziqianlu@bytedance.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/fair: Use throttled_csd_list for local unthrottle
Date: Thu, 04 Jun 2026 18:45:25 -0000	[thread overview]
Message-ID: <178059872549.710.9641795834404322935.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260602050005.11160-3-kprateek.nayak@amd.com>

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     253edcf5436c916f2fbf7b880443c7f1ed76101d
Gitweb:        https://git.kernel.org/tip/253edcf5436c916f2fbf7b880443c7f1ed76101d
Author:        K Prateek Nayak <kprateek.nayak@amd.com>
AuthorDate:    Tue, 02 Jun 2026 05:00:02 
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 02 Jun 2026 12:26:12 +02:00

sched/fair: Use throttled_csd_list for local unthrottle

When distribute_cfs_runtime() encounters a local cfs_rq, it adds it to a
local list and unthrottles it at the end, when it is done unthrottling
other cfs_rq(s) on cfs_b->throttled_cfs_rq until the bandwidth runs out.

Instead of using a local list, reuse the local CPU's
rq->throttled_csd_list and the __cfsb_csd_unthrottle() path for
unthrottle.

If this is the first cfs_rq to be queued on the "throttled_csd_list", it
prevents the need for a remote CPUs to interrupt this local CPU if they
themselves are performing async unthrottle.

If this is not the first cfs_rq on the list, there is an async unthrottle
operation pending on this local CPU and the unthrottle can be batched
together.

No functional changes intended.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Benjamin Segall <bsegall@google.com>
Tested-by: Aaron Lu <ziqianlu@bytedance.com>
Link: https://patch.msgid.link/20260602050005.11160-3-kprateek.nayak@amd.com
---
 kernel/sched/fair.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 261e5ce..26a8bbb 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6991,12 +6991,11 @@ static void unthrottle_cfs_rq_async(struct cfs_rq *cfs_rq)
 
 static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b)
 {
+	bool throttled = false, unthrottle_local = false;
 	int this_cpu = smp_processor_id();
 	u64 runtime, remaining = 1;
-	bool throttled = false;
-	struct cfs_rq *cfs_rq, *tmp;
+	struct cfs_rq *cfs_rq;
 	struct rq *rq;
-	LIST_HEAD(local_unthrottle);
 
 	guard(rcu)();
 
@@ -7047,24 +7046,23 @@ static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b)
 		}
 
 		/*
-		 * We currently only expect to be unthrottling
-		 * a single cfs_rq locally.
+		 * Allow a parallel async unthrottle to unthrottle
+		 * this cfs_rq too via __cfsb_csd_unthrottle().
+		 * If we are first, do it ourselves at the end and
+		 * save on an IPI from remote CPUs.
 		 */
-		WARN_ON_ONCE(!list_empty(&local_unthrottle));
-		list_add_tail(&cfs_rq->throttled_csd_list, &local_unthrottle);
+		unthrottle_local = list_empty(&rq->cfsb_csd_list);
+		list_add_tail(&cfs_rq->throttled_csd_list, &rq->cfsb_csd_list);
 	}
 
-	list_for_each_entry_safe(cfs_rq, tmp, &local_unthrottle,
-				 throttled_csd_list) {
-		struct rq *rq = rq_of(cfs_rq);
-
-		guard(rq_lock_irqsave)(rq);
-
-		list_del_init(&cfs_rq->throttled_csd_list);
-		if (cfs_rq_throttled(cfs_rq))
-			unthrottle_cfs_rq(cfs_rq);
+	if (unthrottle_local) {
+		/*
+		 * Protect against an IPI that is also trying to flush
+		 * the unthrottled cfs_rq(s) from this CPU's csd_list.
+		 */
+		scoped_guard(irqsave)
+			__cfsb_csd_unthrottle(cpu_rq(this_cpu));
 	}
-	WARN_ON_ONCE(!list_empty(&local_unthrottle));
 
 	return throttled;
 }

  reply	other threads:[~2026-06-04 18:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02  5:00 [PATCH v2 0/5] sched/fair: Allow account_cfs_rq_runtime() to throttle current hierarchy K Prateek Nayak
2026-06-02  5:00 ` [PATCH v2 1/5] sched/fair: Convert cfs bandwidth throttling to use guards K Prateek Nayak
2026-06-04 18:45   ` [tip: sched/core] " tip-bot2 for K Prateek Nayak
2026-06-02  5:00 ` [PATCH v2 2/5] sched/fair: Use throttled_csd_list for local unthrottle K Prateek Nayak
2026-06-04 18:45   ` tip-bot2 for K Prateek Nayak [this message]
2026-06-02  5:25 ` [PATCH v2 3/5] sched/fair: Call update_curr() before unthrottling the hierarchy K Prateek Nayak
2026-06-04 18:45   ` [tip: sched/core] " tip-bot2 for K Prateek Nayak
2026-06-02  5:25 ` [PATCH v2 4/5] sched/fair: Move the throttled tasks to a local list in tg_unthrottle_up() K Prateek Nayak
2026-06-04 18:45   ` [tip: sched/core] " tip-bot2 for K Prateek Nayak
2026-06-02  5:25 ` [PATCH v2 5/5] sched/fair: Unify cfs_rq throttling via account_cfs_rq_runtime() K Prateek Nayak
2026-06-02  7:10   ` [PATCH v2.1 " K Prateek Nayak
2026-06-04 18:45     ` [tip: sched/core] " tip-bot2 for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178059872549.710.9641795834404322935.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bsegall@google.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    --cc=ziqianlu@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®