From: tip-bot for Dave Kleikamp <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: peterz@infradead.org, torvalds@linux-foundation.org,
hpa@zytor.com, dave.kleikamp@oracle.com, tglx@linutronix.de,
linux-kernel@vger.kernel.org, mingo@kernel.org
Subject: [tip:sched/core] sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer()
Date: Tue, 23 May 2017 01:46:34 -0700 [thread overview]
Message-ID: <tip-c249f255aab86b9b187ba319b9d2684841ac7c8d@git.kernel.org> (raw)
In-Reply-To: <a767637b-df85-912f-ba69-c90ee00a3fb6@oracle.com>
Commit-ID: c249f255aab86b9b187ba319b9d2684841ac7c8d
Gitweb: http://git.kernel.org/tip/c249f255aab86b9b187ba319b9d2684841ac7c8d
Author: Dave Kleikamp <dave.kleikamp@oracle.com>
AuthorDate: Mon, 15 May 2017 14:14:13 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 23 May 2017 10:01:34 +0200
sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer()
With CONFIG_RT_GROUP_SCHED=y, do_sched_rt_period_timer() sequentially
takes each CPU's rq->lock. On a large, busy system, the cumulative time it
takes to acquire each lock can be excessive, even triggering a watchdog
timeout.
If rt_rq->rt_time and rt_rq->rt_nr_running are both zero, this function does
nothing while holding the lock, so don't bother taking it at all.
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/a767637b-df85-912f-ba69-c90ee00a3fb6@oracle.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/rt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index c18b500..581d5c7 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -840,6 +840,17 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
int enqueue = 0;
struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
struct rq *rq = rq_of_rt_rq(rt_rq);
+ int skip;
+
+ /*
+ * When span == cpu_online_mask, taking each rq->lock
+ * can be time-consuming. Try to avoid it when possible.
+ */
+ raw_spin_lock(&rt_rq->rt_runtime_lock);
+ skip = !rt_rq->rt_time && !rt_rq->rt_nr_running;
+ raw_spin_unlock(&rt_rq->rt_runtime_lock);
+ if (skip)
+ continue;
raw_spin_lock(&rq->lock);
if (rt_rq->rt_time) {
prev parent reply other threads:[~2017-05-23 8:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 19:13 [PATCH RESEND 0/1] sched/rt: minimize rq->lock contention in, do_sched_rt_period_timer() Dave Kleikamp
2017-05-15 19:14 ` [PATCH RESEND 1/1] " Dave Kleikamp
2017-05-16 8:14 ` Peter Zijlstra
2017-05-23 8:46 ` tip-bot for Dave Kleikamp [this message]
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=tip-c249f255aab86b9b187ba319b9d2684841ac7c8d@git.kernel.org \
--to=tipbot@zytor.com \
--cc=dave.kleikamp@oracle.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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
Powered by JetHome