linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] hrtimer: Boring cleanups
@ 2015-08-18 14:18 Frederic Weisbecker
  2015-08-18 14:18 ` [PATCH 1/2] hrtimer: Simplify get_target_base() returning current base Frederic Weisbecker
  2015-08-18 14:18 ` [PATCH 2/2] hrtimer: Unconfuse a bit switch_hrtimer_base Frederic Weisbecker
  0 siblings, 2 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2015-08-18 14:18 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Frederic Weisbecker

Just small clarifications and a tiny simplification.

Thanks.

Frederic Weisbecker (2):
  hrtimer: Simplify get_target_base() returning current base
  hrtimer: Unconfuse a bit switch_hrtimer_base

 kernel/time/hrtimer.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

-- 
2.1.4


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

* [PATCH 1/2] hrtimer: Simplify get_target_base() returning current base
  2015-08-18 14:18 [PATCH 0/2] hrtimer: Boring cleanups Frederic Weisbecker
@ 2015-08-18 14:18 ` Frederic Weisbecker
  2015-08-18 16:39   ` [tip:timers/core] hrtimer: Simplify get_target_base() by " tip-bot for Frederic Weisbecker
  2015-08-18 14:18 ` [PATCH 2/2] hrtimer: Unconfuse a bit switch_hrtimer_base Frederic Weisbecker
  1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2015-08-18 14:18 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Frederic Weisbecker

Instead of fetching again the current cpu base, just take it from the
parameter.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/time/hrtimer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 55575d4..f9eb21b 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -183,7 +183,7 @@ struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 					 int pinned)
 {
 	if (pinned || !base->migration_enabled)
-		return this_cpu_ptr(&hrtimer_bases);
+		return base;
 	return &per_cpu(hrtimer_bases, get_nohz_timer_target());
 }
 #else
@@ -191,7 +191,7 @@ static inline
 struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 					 int pinned)
 {
-	return this_cpu_ptr(&hrtimer_bases);
+	return base;
 }
 #endif
 
-- 
2.1.4


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

* [PATCH 2/2] hrtimer: Unconfuse a bit switch_hrtimer_base
  2015-08-18 14:18 [PATCH 0/2] hrtimer: Boring cleanups Frederic Weisbecker
  2015-08-18 14:18 ` [PATCH 1/2] hrtimer: Simplify get_target_base() returning current base Frederic Weisbecker
@ 2015-08-18 14:18 ` Frederic Weisbecker
  2015-08-18 16:39   ` [tip:timers/core] hrtimer: Unconfuse switch_hrtimer_base() a bit tip-bot for Frederic Weisbecker
  1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2015-08-18 14:18 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Frederic Weisbecker

The variable called "this_base" is confusing because its name suggests
it's of "struct hrtimer_clock_base" type, along with "base" and "new_base"
which doesn't help understanding this complicated function.

Make its name clearer and fix the misleading comments while at it.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/time/hrtimer.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index f9eb21b..1828ed0 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -196,18 +196,20 @@ struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 #endif
 
 /*
- * Switch the timer base to the current CPU when possible.
+ * Switch the timer base to a power-optimized selected CPU target.
+ * If that would involve clock reprogramming, which we can't do on a remote
+ * target, just switch to the current CPU.
  */
 static inline struct hrtimer_clock_base *
 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
 		    int pinned)
 {
-	struct hrtimer_cpu_base *new_cpu_base, *this_base;
+	struct hrtimer_cpu_base *new_cpu_base, *this_cpu_base;
 	struct hrtimer_clock_base *new_base;
 	int basenum = base->index;
 
-	this_base = this_cpu_ptr(&hrtimer_bases);
-	new_cpu_base = get_target_base(this_base, pinned);
+	this_cpu_base = this_cpu_ptr(&hrtimer_bases);
+	new_cpu_base = get_target_base(this_cpu_base, pinned);
 again:
 	new_base = &new_cpu_base->clock_base[basenum];
 
@@ -229,19 +231,19 @@ again:
 		raw_spin_unlock(&base->cpu_base->lock);
 		raw_spin_lock(&new_base->cpu_base->lock);
 
-		if (new_cpu_base != this_base &&
+		if (new_cpu_base != this_cpu_base &&
 		    hrtimer_check_target(timer, new_base)) {
 			raw_spin_unlock(&new_base->cpu_base->lock);
 			raw_spin_lock(&base->cpu_base->lock);
-			new_cpu_base = this_base;
+			new_cpu_base = this_cpu_base;
 			timer->base = base;
 			goto again;
 		}
 		timer->base = new_base;
 	} else {
-		if (new_cpu_base != this_base &&
+		if (new_cpu_base != this_cpu_base &&
 		    hrtimer_check_target(timer, new_base)) {
-			new_cpu_base = this_base;
+			new_cpu_base = this_cpu_base;
 			goto again;
 		}
 	}
-- 
2.1.4


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

* [tip:timers/core] hrtimer: Simplify get_target_base() by returning current base
  2015-08-18 14:18 ` [PATCH 1/2] hrtimer: Simplify get_target_base() returning current base Frederic Weisbecker
@ 2015-08-18 16:39   ` tip-bot for Frederic Weisbecker
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2015-08-18 16:39 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: fweisbec, hpa, tglx, mingo, linux-kernel

Commit-ID:  662b3e194656cc713d51d52780fb71f499c46619
Gitweb:     http://git.kernel.org/tip/662b3e194656cc713d51d52780fb71f499c46619
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Tue, 18 Aug 2015 16:18:28 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 18 Aug 2015 18:36:59 +0200

hrtimer: Simplify get_target_base() by returning current base

Instead of fetching again the current cpu base, just take it from the
parameter.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1439907509-9553-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/hrtimer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 55575d4..f9eb21b 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -183,7 +183,7 @@ struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 					 int pinned)
 {
 	if (pinned || !base->migration_enabled)
-		return this_cpu_ptr(&hrtimer_bases);
+		return base;
 	return &per_cpu(hrtimer_bases, get_nohz_timer_target());
 }
 #else
@@ -191,7 +191,7 @@ static inline
 struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 					 int pinned)
 {
-	return this_cpu_ptr(&hrtimer_bases);
+	return base;
 }
 #endif
 

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

* [tip:timers/core] hrtimer: Unconfuse switch_hrtimer_base() a bit
  2015-08-18 14:18 ` [PATCH 2/2] hrtimer: Unconfuse a bit switch_hrtimer_base Frederic Weisbecker
@ 2015-08-18 16:39   ` tip-bot for Frederic Weisbecker
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2015-08-18 16:39 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: fweisbec, mingo, tglx, hpa, linux-kernel

Commit-ID:  b48362d8aaf32aeb4a75f5c556c652ffeeb1be5d
Gitweb:     http://git.kernel.org/tip/b48362d8aaf32aeb4a75f5c556c652ffeeb1be5d
Author:     Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Tue, 18 Aug 2015 16:18:29 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 18 Aug 2015 18:36:59 +0200

hrtimer: Unconfuse switch_hrtimer_base() a bit

The variable called "this_base" is confusing because its name suggests
it's of "struct hrtimer_clock_base" type, along with "base" and "new_base"
which doesn't help understanding this complicated function.

Make its name clearer and fix the misleading comment while at it.

[ tglx: Fixed the comment for real ]

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1439907509-9553-3-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/hrtimer.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index f9eb21b..5c4fe50 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -196,18 +196,27 @@ struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 #endif
 
 /*
- * Switch the timer base to the current CPU when possible.
+ * We switch the timer base to a power-optimized selected CPU target,
+ * if:
+ *	- NO_HZ_COMMON is enabled
+ *	- timer migration is enabled
+ *	- the timer callback is not running
+ *	- the timer is not the first expiring timer on the new target
+ *
+ * If one of the above requirements is not fulfilled we move the timer
+ * to the current CPU or leave it on the previously assigned CPU if
+ * the timer callback is currently running.
  */
 static inline struct hrtimer_clock_base *
 switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
 		    int pinned)
 {
-	struct hrtimer_cpu_base *new_cpu_base, *this_base;
+	struct hrtimer_cpu_base *new_cpu_base, *this_cpu_base;
 	struct hrtimer_clock_base *new_base;
 	int basenum = base->index;
 
-	this_base = this_cpu_ptr(&hrtimer_bases);
-	new_cpu_base = get_target_base(this_base, pinned);
+	this_cpu_base = this_cpu_ptr(&hrtimer_bases);
+	new_cpu_base = get_target_base(this_cpu_base, pinned);
 again:
 	new_base = &new_cpu_base->clock_base[basenum];
 
@@ -229,19 +238,19 @@ again:
 		raw_spin_unlock(&base->cpu_base->lock);
 		raw_spin_lock(&new_base->cpu_base->lock);
 
-		if (new_cpu_base != this_base &&
+		if (new_cpu_base != this_cpu_base &&
 		    hrtimer_check_target(timer, new_base)) {
 			raw_spin_unlock(&new_base->cpu_base->lock);
 			raw_spin_lock(&base->cpu_base->lock);
-			new_cpu_base = this_base;
+			new_cpu_base = this_cpu_base;
 			timer->base = base;
 			goto again;
 		}
 		timer->base = new_base;
 	} else {
-		if (new_cpu_base != this_base &&
+		if (new_cpu_base != this_cpu_base &&
 		    hrtimer_check_target(timer, new_base)) {
-			new_cpu_base = this_base;
+			new_cpu_base = this_cpu_base;
 			goto again;
 		}
 	}

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

end of thread, other threads:[~2015-08-18 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18 14:18 [PATCH 0/2] hrtimer: Boring cleanups Frederic Weisbecker
2015-08-18 14:18 ` [PATCH 1/2] hrtimer: Simplify get_target_base() returning current base Frederic Weisbecker
2015-08-18 16:39   ` [tip:timers/core] hrtimer: Simplify get_target_base() by " tip-bot for Frederic Weisbecker
2015-08-18 14:18 ` [PATCH 2/2] hrtimer: Unconfuse a bit switch_hrtimer_base Frederic Weisbecker
2015-08-18 16:39   ` [tip:timers/core] hrtimer: Unconfuse switch_hrtimer_base() a bit tip-bot for Frederic Weisbecker

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