linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/1] sched/rt: minimize rq->lock contention in, do_sched_rt_period_timer()
@ 2017-05-15 19:13 Dave Kleikamp
  2017-05-15 19:14 ` [PATCH RESEND 1/1] " Dave Kleikamp
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Kleikamp @ 2017-05-15 19:13 UTC (permalink / raw)
  To: LKML, Peter Zijlstra, Ingo Molnar

Peter, Ingo,

I sent this patch about a month ago and got no response.

https://patchwork.kernel.org/patch/9684545/

Does it seem reasonable? I'm not sure if taking rt_runtime_lock is
strictly necessary, but it's a big improvement to taking rq->lock every
pass through the loop. Is there another way to fix this?

Thanks,
Shaggy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH RESEND 1/1] sched/rt: minimize rq->lock contention in, do_sched_rt_period_timer()
  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 ` Dave Kleikamp
  2017-05-16  8:14   ` Peter Zijlstra
  2017-05-23  8:46   ` [tip:sched/core] sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer() tip-bot for Dave Kleikamp
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Kleikamp @ 2017-05-15 19:14 UTC (permalink / raw)
  To: LKML, Peter Zijlstra, Ingo Molnar

With CONFIG_RT_GROUP_SCHED defined, 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.

Orabug: 25491970

Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/rt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 9f3e40226dec..ae4a8c529a02 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) {
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND 1/1] sched/rt: minimize rq->lock contention in, do_sched_rt_period_timer()
  2017-05-15 19:14 ` [PATCH RESEND 1/1] " Dave Kleikamp
@ 2017-05-16  8:14   ` Peter Zijlstra
  2017-05-23  8:46   ` [tip:sched/core] sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer() tip-bot for Dave Kleikamp
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2017-05-16  8:14 UTC (permalink / raw)
  To: Dave Kleikamp; +Cc: LKML, Ingo Molnar

On Mon, May 15, 2017 at 02:14:13PM -0500, Dave Kleikamp wrote:
> With CONFIG_RT_GROUP_SCHED defined, 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.

Indeed, thanks Dave!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:sched/core] sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer()
  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
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Dave Kleikamp @ 2017-05-23  8:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, hpa, dave.kleikamp, tglx, linux-kernel, mingo

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) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-23  8:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:sched/core] sched/rt: Minimize rq->lock contention in do_sched_rt_period_timer() tip-bot for Dave Kleikamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).