All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Thomas Gleixner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: Catalin.Marinas@arm.com, linux-kernel@vger.kernel.org,
	peterz@infradead.org, sudeep.holla@arm.com, hpa@zytor.com,
	Suzuki.Poulose@arm.com, rafael.j.wysocki@intel.com,
	Lorenzo.Pieralisi@arm.com, preeti@linux.vnet.ibm.com,
	tglx@linutronix.de, mingo@kernel.org
Subject: [tip:timers/urgent] tick/broadcast: Check for hrtimer broadcast active early
Date: Tue, 7 Jul 2015 10:14:53 -0700	[thread overview]
Message-ID: <tip-d5113e13a550bc9c2b53cc9944b8a06453c4a0a1@git.kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.11.1507070929360.3916@nanos>

Commit-ID:  d5113e13a550bc9c2b53cc9944b8a06453c4a0a1
Gitweb:     http://git.kernel.org/tip/d5113e13a550bc9c2b53cc9944b8a06453c4a0a1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 7 Jul 2015 16:43:04 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 7 Jul 2015 18:46:48 +0200

tick/broadcast: Check for hrtimer broadcast active early

If the current cpu is the one which has the hrtimer based broadcast
queued then we better return busy immediately instead of going through
loops and hoops to figure that out.

[ Split out from a larger combo patch ]

Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Suzuki Poulose <Suzuki.Poulose@arm.com>
Cc: Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>
Cc: Catalin Marinas <Catalin.Marinas@arm.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1507070929360.3916@nanos
---
 kernel/time/tick-broadcast.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 70b47bc..c8d731a 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -706,6 +706,17 @@ int __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
 
 	if (state == TICK_BROADCAST_ENTER) {
 		/*
+		 * If the current CPU owns the hrtimer broadcast
+		 * mechanism, it cannot go deep idle and we do not add
+		 * the CPU to the broadcast mask. We don't have to go
+		 * through the EXIT path as the local timer is not
+		 * shutdown.
+		 */
+		ret = broadcast_needs_cpu(bc, cpu);
+		if (ret)
+			goto out;
+
+		/*
 		 * If the broadcast device is in periodic mode, we
 		 * return.
 		 */
@@ -718,7 +729,10 @@ int __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
 
 		if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_oneshot_mask)) {
 			WARN_ON_ONCE(cpumask_test_cpu(cpu, tick_broadcast_pending_mask));
+
+			/* Conditionally shut down the local timer. */
 			broadcast_shutdown_local(bc, dev);
+
 			/*
 			 * We only reprogram the broadcast timer if we
 			 * did not mark ourself in the force mask and
@@ -733,18 +747,20 @@ int __tick_broadcast_oneshot_control(enum tick_broadcast_state state)
 				ret = -EBUSY;
 			} else if (dev->next_event.tv64 < bc->next_event.tv64) {
 				tick_broadcast_set_event(bc, cpu, dev->next_event);
+				/*
+				 * In case of hrtimer broadcasts the
+				 * programming might have moved the
+				 * timer to this cpu. If yes, remove
+				 * us from the broadcast mask and
+				 * return busy.
+				 */
+				ret = broadcast_needs_cpu(bc, cpu);
+				if (ret) {
+					cpumask_clear_cpu(cpu,
+						tick_broadcast_oneshot_mask);
+				}
 			}
 		}
-		/*
-		 * If the current CPU owns the hrtimer broadcast
-		 * mechanism, it cannot go deep idle and we remove the
-		 * CPU from the broadcast mask. We don't have to go
-		 * through the EXIT path as the local timer is not
-		 * shutdown.
-		 */
-		ret = broadcast_needs_cpu(bc, cpu);
-		if (ret)
-			cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
 	} else {
 		if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) {
 			clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);

  parent reply	other threads:[~2015-07-07 17:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-05 20:53 [patch 0/2] tic/broadcast: Plug a few corner cases which cause malfunction Thomas Gleixner
2015-07-05 20:53 ` [patch 1/2] tick/broadcast: Prevent deep idle states if no broadcast device available Thomas Gleixner
2015-07-06 15:09   ` Sudeep Holla
2015-07-06 15:35     ` Thomas Gleixner
2015-07-06 15:44       ` Sudeep Holla
2015-07-06 16:06         ` Thomas Gleixner
2015-07-06 16:27           ` Sudeep Holla
2015-07-06 16:53             ` Thomas Gleixner
2015-07-06 17:57               ` Sudeep Holla
2015-07-06 19:56                 ` Thomas Gleixner
2015-07-07  7:31                   ` Thomas Gleixner
2015-07-07 11:25                     ` Sudeep Holla
2015-07-07 11:55                       ` Thomas Gleixner
2015-07-07 17:12                     ` [tip:timers/urgent] tick/broadcast: Prevent hrtimer recursion tip-bot for Thomas Gleixner
2015-07-07 17:12                     ` [tip:timers/urgent] tick/broadcast: Sanity check the shutdown of the local clock_event tip-bot for Thomas Gleixner
2015-07-07 17:13                     ` [tip:timers/urgent] tick/broadcast: Make idle check independent from mode and config tip-bot for Thomas Gleixner
2015-07-07 17:13                     ` [tip:timers/urgent] tick/broadcast: Prevent deep idle if no broadcast device available tip-bot for Thomas Gleixner
2015-07-07 17:13                     ` [tip:timers/urgent] tick/broadcast: Move the check for periodic mode inside state handling tip-bot for Thomas Gleixner
2015-07-07 17:14                     ` [tip:timers/urgent] tick/broadcast: Return busy if periodic mode and hrtimer broadcast tip-bot for Thomas Gleixner
2015-07-07 17:14                     ` [tip:timers/urgent] tick/broadcast: Return busy when IPI is pending tip-bot for Thomas Gleixner
2015-07-07 17:14                     ` tip-bot for Thomas Gleixner [this message]
2015-07-05 20:53 ` [patch 2/2] tick/broadcast: Handle spurious interrupts gracefully Thomas Gleixner
2015-07-06 15:17   ` Sudeep Holla
2015-07-06 15:36     ` Thomas Gleixner
2015-07-07 17:15   ` [tip:timers/urgent] " tip-bot for Thomas Gleixner

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-d5113e13a550bc9c2b53cc9944b8a06453c4a0a1@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Lorenzo.Pieralisi@arm.com \
    --cc=Suzuki.Poulose@arm.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=preeti@linux.vnet.ibm.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=sudeep.holla@arm.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.