@@ -64,17 +64,20 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
6464 .clock_base =
6565 {
6666 {
67- .index = CLOCK_REALTIME ,
67+ .index = HRTIMER_BASE_REALTIME ,
68+ .clockid = CLOCK_REALTIME ,
6869 .get_time = & ktime_get_real ,
6970 .resolution = KTIME_LOW_RES ,
7071 },
7172 {
72- .index = CLOCK_MONOTONIC ,
73+ .index = HRTIMER_BASE_MONOTONIC ,
74+ .clockid = CLOCK_MONOTONIC ,
7375 .get_time = & ktime_get ,
7476 .resolution = KTIME_LOW_RES ,
7577 },
7678 {
77- .index = CLOCK_BOOTTIME ,
79+ .index = HRTIMER_BASE_BOOTTIME ,
80+ .clockid = CLOCK_BOOTTIME ,
7881 .get_time = & ktime_get_boottime ,
7982 .resolution = KTIME_LOW_RES ,
8083 },
@@ -196,7 +199,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
196199 struct hrtimer_cpu_base * new_cpu_base ;
197200 int this_cpu = smp_processor_id ();
198201 int cpu = hrtimer_get_target (this_cpu , pinned );
199- int basenum = hrtimer_clockid_to_base ( base -> index ) ;
202+ int basenum = base -> index ;
200203
201204again :
202205 new_cpu_base = & per_cpu (hrtimer_bases , cpu );
@@ -857,6 +860,7 @@ static int enqueue_hrtimer(struct hrtimer *timer,
857860 debug_activate (timer );
858861
859862 timerqueue_add (& base -> active , & timer -> node );
863+ base -> cpu_base -> active_bases |= 1 << base -> index ;
860864
861865 /*
862866 * HRTIMER_STATE_ENQUEUED is or'ed to the current state to preserve the
@@ -898,6 +902,8 @@ static void __remove_hrtimer(struct hrtimer *timer,
898902#endif
899903 }
900904 timerqueue_del (& base -> active , & timer -> node );
905+ if (!timerqueue_getnext (& base -> active ))
906+ base -> cpu_base -> active_bases &= ~(1 << base -> index );
901907out :
902908 timer -> state = newstate ;
903909}
@@ -1235,7 +1241,6 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
12351241void hrtimer_interrupt (struct clock_event_device * dev )
12361242{
12371243 struct hrtimer_cpu_base * cpu_base = & __get_cpu_var (hrtimer_bases );
1238- struct hrtimer_clock_base * base ;
12391244 ktime_t expires_next , now , entry_time , delta ;
12401245 int i , retries = 0 ;
12411246
@@ -1257,12 +1262,15 @@ void hrtimer_interrupt(struct clock_event_device *dev)
12571262 */
12581263 cpu_base -> expires_next .tv64 = KTIME_MAX ;
12591264
1260- base = cpu_base -> clock_base ;
1261-
12621265 for (i = 0 ; i < HRTIMER_MAX_CLOCK_BASES ; i ++ ) {
1263- ktime_t basenow ;
1266+ struct hrtimer_clock_base * base ;
12641267 struct timerqueue_node * node ;
1268+ ktime_t basenow ;
1269+
1270+ if (!(cpu_base -> active_bases & (1 << i )))
1271+ continue ;
12651272
1273+ base = cpu_base -> clock_base + i ;
12661274 basenow = ktime_add (now , base -> offset );
12671275
12681276 while ((node = timerqueue_getnext (& base -> active ))) {
@@ -1295,7 +1303,6 @@ void hrtimer_interrupt(struct clock_event_device *dev)
12951303
12961304 __run_hrtimer (timer , & basenow );
12971305 }
1298- base ++ ;
12991306 }
13001307
13011308 /*
@@ -1526,7 +1533,7 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
15261533 struct timespec __user * rmtp ;
15271534 int ret = 0 ;
15281535
1529- hrtimer_init_on_stack (& t .timer , restart -> nanosleep .index ,
1536+ hrtimer_init_on_stack (& t .timer , restart -> nanosleep .clockid ,
15301537 HRTIMER_MODE_ABS );
15311538 hrtimer_set_expires_tv64 (& t .timer , restart -> nanosleep .expires );
15321539
@@ -1578,7 +1585,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
15781585
15791586 restart = & current_thread_info ()-> restart_block ;
15801587 restart -> fn = hrtimer_nanosleep_restart ;
1581- restart -> nanosleep .index = t .timer .base -> index ;
1588+ restart -> nanosleep .clockid = t .timer .base -> clockid ;
15821589 restart -> nanosleep .rmtp = rmtp ;
15831590 restart -> nanosleep .expires = hrtimer_get_expires_tv64 (& t .timer );
15841591
0 commit comments