Skip to content

Commit b48362d

Browse files
fweisbecKAGA-KOKO
authored andcommitted
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>
1 parent 662b3e1 commit b48362d

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎kernel/time/hrtimer.c‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,27 @@ struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
196196
#endif
197197

198198
/*
199-
* Switch the timer base to the current CPU when possible.
199+
* We switch the timer base to a power-optimized selected CPU target,
200+
* if:
201+
* - NO_HZ_COMMON is enabled
202+
* - timer migration is enabled
203+
* - the timer callback is not running
204+
* - the timer is not the first expiring timer on the new target
205+
*
206+
* If one of the above requirements is not fulfilled we move the timer
207+
* to the current CPU or leave it on the previously assigned CPU if
208+
* the timer callback is currently running.
200209
*/
201210
static inline struct hrtimer_clock_base *
202211
switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
203212
int pinned)
204213
{
205-
struct hrtimer_cpu_base *new_cpu_base, *this_base;
214+
struct hrtimer_cpu_base *new_cpu_base, *this_cpu_base;
206215
struct hrtimer_clock_base *new_base;
207216
int basenum = base->index;
208217

209-
this_base = this_cpu_ptr(&hrtimer_bases);
210-
new_cpu_base = get_target_base(this_base, pinned);
218+
this_cpu_base = this_cpu_ptr(&hrtimer_bases);
219+
new_cpu_base = get_target_base(this_cpu_base, pinned);
211220
again:
212221
new_base = &new_cpu_base->clock_base[basenum];
213222

@@ -229,19 +238,19 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
229238
raw_spin_unlock(&base->cpu_base->lock);
230239
raw_spin_lock(&new_base->cpu_base->lock);
231240

232-
if (new_cpu_base != this_base &&
241+
if (new_cpu_base != this_cpu_base &&
233242
hrtimer_check_target(timer, new_base)) {
234243
raw_spin_unlock(&new_base->cpu_base->lock);
235244
raw_spin_lock(&base->cpu_base->lock);
236-
new_cpu_base = this_base;
245+
new_cpu_base = this_cpu_base;
237246
timer->base = base;
238247
goto again;
239248
}
240249
timer->base = new_base;
241250
} else {
242-
if (new_cpu_base != this_base &&
251+
if (new_cpu_base != this_cpu_base &&
243252
hrtimer_check_target(timer, new_base)) {
244-
new_cpu_base = this_base;
253+
new_cpu_base = this_cpu_base;
245254
goto again;
246255
}
247256
}

0 commit comments

Comments
 (0)