All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hrtimers: conditionally lock/unlock spinlock in hrtimer_get_next_event
@ 2014-06-09  9:23 Stanislav Fomichev
  2014-06-09  9:27 ` Viresh Kumar
  2014-06-09 11:06 ` Thomas Gleixner
  0 siblings, 2 replies; 9+ messages in thread
From: Stanislav Fomichev @ 2014-06-09  9:23 UTC (permalink / raw)
  To: tglx, stfomichev, viresh.kumar, paul.gortmaker, peterz,
	stuart.w.hayes, david.vrabel
  Cc: linux-kernel

In hrtimer_get_next_event we unconditionally lock/unlock spinlock, even if it's
not required (hrtimer_hres_active() != 0). This patch moves
locking/unlocking and mindelta range check inside the if clause,
so we don't execute unnecessary operations.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 kernel/hrtimer.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 39f339dcbe93..ce21e5f6bcf0 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -1166,9 +1166,9 @@ ktime_t hrtimer_get_next_event(void)
 	unsigned long flags;
 	int i;
 
-	raw_spin_lock_irqsave(&cpu_base->lock, flags);
-
 	if (!hrtimer_hres_active()) {
+		raw_spin_lock_irqsave(&cpu_base->lock, flags);
+
 		for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) {
 			struct hrtimer *timer;
 			struct timerqueue_node *next;
@@ -1183,12 +1183,13 @@ ktime_t hrtimer_get_next_event(void)
 			if (delta.tv64 < mindelta.tv64)
 				mindelta.tv64 = delta.tv64;
 		}
-	}
 
-	raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
+		raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
+
+		if (mindelta.tv64 < 0)
+			mindelta.tv64 = 0;
+	}
 
-	if (mindelta.tv64 < 0)
-		mindelta.tv64 = 0;
 	return mindelta;
 }
 #endif
-- 
1.8.3.2


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

end of thread, other threads:[~2014-06-10  9:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-09  9:23 [PATCH] hrtimers: conditionally lock/unlock spinlock in hrtimer_get_next_event Stanislav Fomichev
2014-06-09  9:27 ` Viresh Kumar
2014-06-09 11:06 ` Thomas Gleixner
2014-06-09 11:11   ` Stanislav Fomichev
2014-06-09 12:59     ` [PATCH v2] hrtimers: add fast path to hrtimer_get_next_event Stanislav Fomichev
2014-06-09 13:28       ` Viresh Kumar
2014-06-10  7:42         ` Peter Zijlstra
2014-06-09 14:44       ` Thomas Gleixner
2014-06-10  9:46         ` [PATCH v3] " Stanislav Fomichev

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.