mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Mason <chris.mason@oracle.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 4/4] Avoid broadcast time lock when not changing the timeout
Date: Fri,  6 May 2011 14:40:56 -0700	[thread overview]
Message-ID: <1304718056-20206-5-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1304718056-20206-1-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

Don't take the global lock when the new timeout is larger than the
old timeout.

The timeout on the broadcast device should never shrink, so this
is safe to do.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 kernel/time/tick-broadcast.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index c1587cb..4776742 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -524,6 +524,17 @@ static void set_broadcast_sibling_state(int cpu, int enter)
 	}
 }
 
+static void set_broadcast_timeout(ktime_t to, struct clock_event_device *bc)
+{
+	unsigned long flags;
+
+	if (to.tv64 < bc->next_event.tv64) {
+		raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
+		tick_broadcast_set_event(to, 1);
+		raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+	}
+}
+
 /*
  * Powerstate information: The system enters/leaves a state, where
  * affected devices might stop
@@ -532,7 +543,6 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 {
 	struct clock_event_device *bc, *dev;
 	struct tick_device *td;
-	unsigned long flags;
 	int cpu;
 	ktime_t timeout;
 	
@@ -556,14 +566,12 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 				reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER))
 		return;
 
-	raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 	if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
 		if (!__get_cpu_var(state).need_oneshot) {
 			/* Turn all slaves into oneshots */
 			set_broadcast_sibling_state(cpu, 1);
 			clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
-			if (timeout.tv64 < bc->next_event.tv64)
-				tick_broadcast_set_event(timeout, 1);
+			set_broadcast_timeout(timeout, bc);
 		}
 	} else {
 		if (__get_cpu_var(state).need_oneshot) {
@@ -574,7 +582,6 @@ void tick_broadcast_oneshot_control(unsigned long reason)
 				tick_program_event(dev->next_event, 1);
 		}
 	}
-	raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 /*
-- 
1.7.4.4


      parent reply	other threads:[~2011-05-06 21:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06 21:40 RFC: Lower broadcast timer idle path lock contention Andi Kleen
2011-05-06 21:40 ` [PATCH 1/4] Move C3 stop test outside lock Andi Kleen
2011-05-06 21:40 ` [PATCH 2/4] Move oneshot broadcast mask to per cpu variables Andi Kleen
2011-05-06 21:40 ` [PATCH 3/4] Avoid tick broadcast switch-overs for thread siblings Andi Kleen
2011-05-07  5:32   ` Dave Kleikamp
2011-05-06 21:40 ` Andi Kleen [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=1304718056-20206-5-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.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

Powered by JetHome