diff options
-rw-r--r-- | include/linux/timer.h | 6 | ||||
-rw-r--r-- | kernel/timer.c | 80 |
2 files changed, 42 insertions, 44 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h index 78cf899b4409..de0e71359ede 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/ktime.h> | 5 | #include <linux/ktime.h> |
6 | #include <linux/stddef.h> | 6 | #include <linux/stddef.h> |
7 | 7 | ||
8 | struct tvec_t_base_s; | 8 | struct tvec_base; |
9 | 9 | ||
10 | struct timer_list { | 10 | struct timer_list { |
11 | struct list_head entry; | 11 | struct list_head entry; |
@@ -14,7 +14,7 @@ struct timer_list { | |||
14 | void (*function)(unsigned long); | 14 | void (*function)(unsigned long); |
15 | unsigned long data; | 15 | unsigned long data; |
16 | 16 | ||
17 | struct tvec_t_base_s *base; | 17 | struct tvec_base *base; |
18 | #ifdef CONFIG_TIMER_STATS | 18 | #ifdef CONFIG_TIMER_STATS |
19 | void *start_site; | 19 | void *start_site; |
20 | char start_comm[16]; | 20 | char start_comm[16]; |
@@ -22,7 +22,7 @@ struct timer_list { | |||
22 | #endif | 22 | #endif |
23 | }; | 23 | }; |
24 | 24 | ||
25 | extern struct tvec_t_base_s boot_tvec_bases; | 25 | extern struct tvec_base boot_tvec_bases; |
26 | 26 | ||
27 | #define TIMER_INITIALIZER(_function, _expires, _data) { \ | 27 | #define TIMER_INITIALIZER(_function, _expires, _data) { \ |
28 | .function = (_function), \ | 28 | .function = (_function), \ |
diff --git a/kernel/timer.c b/kernel/timer.c index f739dfb539ce..aadfbc8367f5 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -58,59 +58,57 @@ EXPORT_SYMBOL(jiffies_64); | |||
58 | #define TVN_MASK (TVN_SIZE - 1) | 58 | #define TVN_MASK (TVN_SIZE - 1) |
59 | #define TVR_MASK (TVR_SIZE - 1) | 59 | #define TVR_MASK (TVR_SIZE - 1) |
60 | 60 | ||
61 | typedef struct tvec_s { | 61 | struct tvec { |
62 | struct list_head vec[TVN_SIZE]; | 62 | struct list_head vec[TVN_SIZE]; |
63 | } tvec_t; | 63 | }; |
64 | 64 | ||
65 | typedef struct tvec_root_s { | 65 | struct tvec_root { |
66 | struct list_head vec[TVR_SIZE]; | 66 | struct list_head vec[TVR_SIZE]; |
67 | } tvec_root_t; | 67 | }; |
68 | 68 | ||
69 | struct tvec_t_base_s { | 69 | struct tvec_base { |
70 | spinlock_t lock; | 70 | spinlock_t lock; |
71 | struct timer_list *running_timer; | 71 | struct timer_list *running_timer; |
72 | unsigned long timer_jiffies; | 72 | unsigned long timer_jiffies; |
73 | tvec_root_t tv1; | 73 | struct tvec_root tv1; |
74 | tvec_t tv2; | 74 | struct tvec tv2; |
75 | tvec_t tv3; | 75 | struct tvec tv3; |
76 | tvec_t tv4; | 76 | struct tvec tv4; |
77 | tvec_t tv5; | 77 | struct tvec tv5; |
78 | } ____cacheline_aligned; | 78 | } ____cacheline_aligned; |
79 | 79 | ||
80 | typedef struct tvec_t_base_s tvec_base_t; | 80 | struct tvec_base boot_tvec_bases; |
81 | |||
82 | tvec_base_t boot_tvec_bases; | ||
83 | EXPORT_SYMBOL(boot_tvec_bases); | 81 | EXPORT_SYMBOL(boot_tvec_bases); |
84 | static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases; | 82 | static DEFINE_PER_CPU(struct tvec_base *, tvec_bases) = &boot_tvec_bases; |
85 | 83 | ||
86 | /* | 84 | /* |
87 | * Note that all tvec_bases is 2 byte aligned and lower bit of | 85 | * Note that all tvec_bases are 2 byte aligned and lower bit of |
88 | * base in timer_list is guaranteed to be zero. Use the LSB for | 86 | * base in timer_list is guaranteed to be zero. Use the LSB for |
89 | * the new flag to indicate whether the timer is deferrable | 87 | * the new flag to indicate whether the timer is deferrable |
90 | */ | 88 | */ |
91 | #define TBASE_DEFERRABLE_FLAG (0x1) | 89 | #define TBASE_DEFERRABLE_FLAG (0x1) |
92 | 90 | ||
93 | /* Functions below help us manage 'deferrable' flag */ | 91 | /* Functions below help us manage 'deferrable' flag */ |
94 | static inline unsigned int tbase_get_deferrable(tvec_base_t *base) | 92 | static inline unsigned int tbase_get_deferrable(struct tvec_base *base) |
95 | { | 93 | { |
96 | return ((unsigned int)(unsigned long)base & TBASE_DEFERRABLE_FLAG); | 94 | return ((unsigned int)(unsigned long)base & TBASE_DEFERRABLE_FLAG); |
97 | } | 95 | } |
98 | 96 | ||
99 | static inline tvec_base_t *tbase_get_base(tvec_base_t *base) | 97 | static inline struct tvec_base *tbase_get_base(struct tvec_base *base) |
100 | { | 98 | { |
101 | return ((tvec_base_t *)((unsigned long)base & ~TBASE_DEFERRABLE_FLAG)); | 99 | return ((struct tvec_base *)((unsigned long)base & ~TBASE_DEFERRABLE_FLAG)); |
102 | } | 100 | } |
103 | 101 | ||
104 | static inline void timer_set_deferrable(struct timer_list *timer) | 102 | static inline void timer_set_deferrable(struct timer_list *timer) |
105 | { | 103 | { |
106 | timer->base = ((tvec_base_t *)((unsigned long)(timer->base) | | 104 | timer->base = ((struct tvec_base *)((unsigned long)(timer->base) | |
107 | TBASE_DEFERRABLE_FLAG)); | 105 | TBASE_DEFERRABLE_FLAG)); |
108 | } | 106 | } |
109 | 107 | ||
110 | static inline void | 108 | static inline void |
111 | timer_set_base(struct timer_list *timer, tvec_base_t *new_base) | 109 | timer_set_base(struct timer_list *timer, struct tvec_base *new_base) |
112 | { | 110 | { |
113 | timer->base = (tvec_base_t *)((unsigned long)(new_base) | | 111 | timer->base = (struct tvec_base *)((unsigned long)(new_base) | |
114 | tbase_get_deferrable(timer->base)); | 112 | tbase_get_deferrable(timer->base)); |
115 | } | 113 | } |
116 | 114 | ||
@@ -246,7 +244,7 @@ unsigned long round_jiffies_relative(unsigned long j) | |||
246 | EXPORT_SYMBOL_GPL(round_jiffies_relative); | 244 | EXPORT_SYMBOL_GPL(round_jiffies_relative); |
247 | 245 | ||
248 | 246 | ||
249 | static inline void set_running_timer(tvec_base_t *base, | 247 | static inline void set_running_timer(struct tvec_base *base, |
250 | struct timer_list *timer) | 248 | struct timer_list *timer) |
251 | { | 249 | { |
252 | #ifdef CONFIG_SMP | 250 | #ifdef CONFIG_SMP |
@@ -254,7 +252,7 @@ static inline void set_running_timer(tvec_base_t *base, | |||
254 | #endif | 252 | #endif |
255 | } | 253 | } |
256 | 254 | ||
257 | static void internal_add_timer(tvec_base_t *base, struct timer_list *timer) | 255 | static void internal_add_timer(struct tvec_base *base, struct timer_list *timer) |
258 | { | 256 | { |
259 | unsigned long expires = timer->expires; | 257 | unsigned long expires = timer->expires; |
260 | unsigned long idx = expires - base->timer_jiffies; | 258 | unsigned long idx = expires - base->timer_jiffies; |
@@ -371,14 +369,14 @@ static inline void detach_timer(struct timer_list *timer, | |||
371 | * possible to set timer->base = NULL and drop the lock: the timer remains | 369 | * possible to set timer->base = NULL and drop the lock: the timer remains |
372 | * locked. | 370 | * locked. |
373 | */ | 371 | */ |
374 | static tvec_base_t *lock_timer_base(struct timer_list *timer, | 372 | static struct tvec_base *lock_timer_base(struct timer_list *timer, |
375 | unsigned long *flags) | 373 | unsigned long *flags) |
376 | __acquires(timer->base->lock) | 374 | __acquires(timer->base->lock) |
377 | { | 375 | { |
378 | tvec_base_t *base; | 376 | struct tvec_base *base; |
379 | 377 | ||
380 | for (;;) { | 378 | for (;;) { |
381 | tvec_base_t *prelock_base = timer->base; | 379 | struct tvec_base *prelock_base = timer->base; |
382 | base = tbase_get_base(prelock_base); | 380 | base = tbase_get_base(prelock_base); |
383 | if (likely(base != NULL)) { | 381 | if (likely(base != NULL)) { |
384 | spin_lock_irqsave(&base->lock, *flags); | 382 | spin_lock_irqsave(&base->lock, *flags); |
@@ -393,7 +391,7 @@ static tvec_base_t *lock_timer_base(struct timer_list *timer, | |||
393 | 391 | ||
394 | int __mod_timer(struct timer_list *timer, unsigned long expires) | 392 | int __mod_timer(struct timer_list *timer, unsigned long expires) |
395 | { | 393 | { |
396 | tvec_base_t *base, *new_base; | 394 | struct tvec_base *base, *new_base; |
397 | unsigned long flags; | 395 | unsigned long flags; |
398 | int ret = 0; | 396 | int ret = 0; |
399 | 397 | ||
@@ -445,7 +443,7 @@ EXPORT_SYMBOL(__mod_timer); | |||
445 | */ | 443 | */ |
446 | void add_timer_on(struct timer_list *timer, int cpu) | 444 | void add_timer_on(struct timer_list *timer, int cpu) |
447 | { | 445 | { |
448 | tvec_base_t *base = per_cpu(tvec_bases, cpu); | 446 | struct tvec_base *base = per_cpu(tvec_bases, cpu); |
449 | unsigned long flags; | 447 | unsigned long flags; |
450 | 448 | ||
451 | timer_stats_timer_set_start_info(timer); | 449 | timer_stats_timer_set_start_info(timer); |
@@ -508,7 +506,7 @@ EXPORT_SYMBOL(mod_timer); | |||
508 | */ | 506 | */ |
509 | int del_timer(struct timer_list *timer) | 507 | int del_timer(struct timer_list *timer) |
510 | { | 508 | { |
511 | tvec_base_t *base; | 509 | struct tvec_base *base; |
512 | unsigned long flags; | 510 | unsigned long flags; |
513 | int ret = 0; | 511 | int ret = 0; |
514 | 512 | ||
@@ -539,7 +537,7 @@ EXPORT_SYMBOL(del_timer); | |||
539 | */ | 537 | */ |
540 | int try_to_del_timer_sync(struct timer_list *timer) | 538 | int try_to_del_timer_sync(struct timer_list *timer) |
541 | { | 539 | { |
542 | tvec_base_t *base; | 540 | struct tvec_base *base; |
543 | unsigned long flags; | 541 | unsigned long flags; |
544 | int ret = -1; | 542 | int ret = -1; |
545 | 543 | ||
@@ -591,7 +589,7 @@ int del_timer_sync(struct timer_list *timer) | |||
591 | EXPORT_SYMBOL(del_timer_sync); | 589 | EXPORT_SYMBOL(del_timer_sync); |
592 | #endif | 590 | #endif |
593 | 591 | ||
594 | static int cascade(tvec_base_t *base, tvec_t *tv, int index) | 592 | static int cascade(struct tvec_base *base, struct tvec *tv, int index) |
595 | { | 593 | { |
596 | /* cascade all the timers from tv up one level */ | 594 | /* cascade all the timers from tv up one level */ |
597 | struct timer_list *timer, *tmp; | 595 | struct timer_list *timer, *tmp; |
@@ -620,7 +618,7 @@ static int cascade(tvec_base_t *base, tvec_t *tv, int index) | |||
620 | * This function cascades all vectors and executes all expired timer | 618 | * This function cascades all vectors and executes all expired timer |
621 | * vectors. | 619 | * vectors. |
622 | */ | 620 | */ |
623 | static inline void __run_timers(tvec_base_t *base) | 621 | static inline void __run_timers(struct tvec_base *base) |
624 | { | 622 | { |
625 | struct timer_list *timer; | 623 | struct timer_list *timer; |
626 | 624 | ||
@@ -678,13 +676,13 @@ static inline void __run_timers(tvec_base_t *base) | |||
678 | * is used on S/390 to stop all activity when a cpus is idle. | 676 | * is used on S/390 to stop all activity when a cpus is idle. |
679 | * This functions needs to be called disabled. | 677 | * This functions needs to be called disabled. |
680 | */ | 678 | */ |
681 | static unsigned long __next_timer_interrupt(tvec_base_t *base) | 679 | static unsigned long __next_timer_interrupt(struct tvec_base *base) |
682 | { | 680 | { |
683 | unsigned long timer_jiffies = base->timer_jiffies; | 681 | unsigned long timer_jiffies = base->timer_jiffies; |
684 | unsigned long expires = timer_jiffies + NEXT_TIMER_MAX_DELTA; | 682 | unsigned long expires = timer_jiffies + NEXT_TIMER_MAX_DELTA; |
685 | int index, slot, array, found = 0; | 683 | int index, slot, array, found = 0; |
686 | struct timer_list *nte; | 684 | struct timer_list *nte; |
687 | tvec_t *varray[4]; | 685 | struct tvec *varray[4]; |
688 | 686 | ||
689 | /* Look for timer events in tv1. */ | 687 | /* Look for timer events in tv1. */ |
690 | index = slot = timer_jiffies & TVR_MASK; | 688 | index = slot = timer_jiffies & TVR_MASK; |
@@ -716,7 +714,7 @@ cascade: | |||
716 | varray[3] = &base->tv5; | 714 | varray[3] = &base->tv5; |
717 | 715 | ||
718 | for (array = 0; array < 4; array++) { | 716 | for (array = 0; array < 4; array++) { |
719 | tvec_t *varp = varray[array]; | 717 | struct tvec *varp = varray[array]; |
720 | 718 | ||
721 | index = slot = timer_jiffies & TVN_MASK; | 719 | index = slot = timer_jiffies & TVN_MASK; |
722 | do { | 720 | do { |
@@ -795,7 +793,7 @@ static unsigned long cmp_next_hrtimer_event(unsigned long now, | |||
795 | */ | 793 | */ |
796 | unsigned long get_next_timer_interrupt(unsigned long now) | 794 | unsigned long get_next_timer_interrupt(unsigned long now) |
797 | { | 795 | { |
798 | tvec_base_t *base = __get_cpu_var(tvec_bases); | 796 | struct tvec_base *base = __get_cpu_var(tvec_bases); |
799 | unsigned long expires; | 797 | unsigned long expires; |
800 | 798 | ||
801 | spin_lock(&base->lock); | 799 | spin_lock(&base->lock); |
@@ -894,7 +892,7 @@ static inline void calc_load(unsigned long ticks) | |||
894 | */ | 892 | */ |
895 | static void run_timer_softirq(struct softirq_action *h) | 893 | static void run_timer_softirq(struct softirq_action *h) |
896 | { | 894 | { |
897 | tvec_base_t *base = __get_cpu_var(tvec_bases); | 895 | struct tvec_base *base = __get_cpu_var(tvec_bases); |
898 | 896 | ||
899 | hrtimer_run_pending(); | 897 | hrtimer_run_pending(); |
900 | 898 | ||
@@ -1223,7 +1221,7 @@ static struct lock_class_key base_lock_keys[NR_CPUS]; | |||
1223 | static int __cpuinit init_timers_cpu(int cpu) | 1221 | static int __cpuinit init_timers_cpu(int cpu) |
1224 | { | 1222 | { |
1225 | int j; | 1223 | int j; |
1226 | tvec_base_t *base; | 1224 | struct tvec_base *base; |
1227 | static char __cpuinitdata tvec_base_done[NR_CPUS]; | 1225 | static char __cpuinitdata tvec_base_done[NR_CPUS]; |
1228 | 1226 | ||
1229 | if (!tvec_base_done[cpu]) { | 1227 | if (!tvec_base_done[cpu]) { |
@@ -1278,7 +1276,7 @@ static int __cpuinit init_timers_cpu(int cpu) | |||
1278 | } | 1276 | } |
1279 | 1277 | ||
1280 | #ifdef CONFIG_HOTPLUG_CPU | 1278 | #ifdef CONFIG_HOTPLUG_CPU |
1281 | static void migrate_timer_list(tvec_base_t *new_base, struct list_head *head) | 1279 | static void migrate_timer_list(struct tvec_base *new_base, struct list_head *head) |
1282 | { | 1280 | { |
1283 | struct timer_list *timer; | 1281 | struct timer_list *timer; |
1284 | 1282 | ||
@@ -1292,8 +1290,8 @@ static void migrate_timer_list(tvec_base_t *new_base, struct list_head *head) | |||
1292 | 1290 | ||
1293 | static void __cpuinit migrate_timers(int cpu) | 1291 | static void __cpuinit migrate_timers(int cpu) |
1294 | { | 1292 | { |
1295 | tvec_base_t *old_base; | 1293 | struct tvec_base *old_base; |
1296 | tvec_base_t *new_base; | 1294 | struct tvec_base *new_base; |
1297 | int i; | 1295 | int i; |
1298 | 1296 | ||
1299 | BUG_ON(cpu_online(cpu)); | 1297 | BUG_ON(cpu_online(cpu)); |