diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2007-02-16 04:27:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-16 11:13:58 -0500 |
commit | 3c8aa39d7c445ae2612b6b626f76f077e7a7ab0d (patch) | |
tree | 8e07fc3dbddc0d5a8be3ecda491ec4410c90ed6b /include/linux/hrtimer.h | |
parent | c9cb2e3d7c9178ab75d0942f96abb3abe0369906 (diff) |
[PATCH] hrtimers: cleanup locking
Improve kernel/hrtimers.c locking: use a per-CPU base with a lock to control
locking of all clocks belonging to a CPU. This simplifies code that needs to
lock all clocks at once. This makes life easier for high-res timers and
dyntick.
No functional changes.
[ optimization change from Andrew Morton <akpm@osdl.org> ]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/hrtimer.h')
-rw-r--r-- | include/linux/hrtimer.h | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 44c7d280b1a5..e00fc4d3d74f 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -21,6 +21,9 @@ | |||
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
23 | 23 | ||
24 | struct hrtimer_clock_base; | ||
25 | struct hrtimer_cpu_base; | ||
26 | |||
24 | /* | 27 | /* |
25 | * Mode arguments of xxx_hrtimer functions: | 28 | * Mode arguments of xxx_hrtimer functions: |
26 | */ | 29 | */ |
@@ -37,8 +40,6 @@ enum hrtimer_restart { | |||
37 | HRTIMER_RESTART, /* Timer must be restarted */ | 40 | HRTIMER_RESTART, /* Timer must be restarted */ |
38 | }; | 41 | }; |
39 | 42 | ||
40 | struct hrtimer_base; | ||
41 | |||
42 | /** | 43 | /** |
43 | * struct hrtimer - the basic hrtimer structure | 44 | * struct hrtimer - the basic hrtimer structure |
44 | * @node: red black tree node for time ordered insertion | 45 | * @node: red black tree node for time ordered insertion |
@@ -51,10 +52,10 @@ struct hrtimer_base; | |||
51 | * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE() | 52 | * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE() |
52 | */ | 53 | */ |
53 | struct hrtimer { | 54 | struct hrtimer { |
54 | struct rb_node node; | 55 | struct rb_node node; |
55 | ktime_t expires; | 56 | ktime_t expires; |
56 | enum hrtimer_restart (*function)(struct hrtimer *); | 57 | enum hrtimer_restart (*function)(struct hrtimer *); |
57 | struct hrtimer_base *base; | 58 | struct hrtimer_clock_base *base; |
58 | }; | 59 | }; |
59 | 60 | ||
60 | /** | 61 | /** |
@@ -71,29 +72,41 @@ struct hrtimer_sleeper { | |||
71 | 72 | ||
72 | /** | 73 | /** |
73 | * struct hrtimer_base - the timer base for a specific clock | 74 | * struct hrtimer_base - the timer base for a specific clock |
74 | * @index: clock type index for per_cpu support when moving a timer | 75 | * @index: clock type index for per_cpu support when moving a |
75 | * to a base on another cpu. | 76 | * timer to a base on another cpu. |
76 | * @lock: lock protecting the base and associated timers | ||
77 | * @active: red black tree root node for the active timers | 77 | * @active: red black tree root node for the active timers |
78 | * @first: pointer to the timer node which expires first | 78 | * @first: pointer to the timer node which expires first |
79 | * @resolution: the resolution of the clock, in nanoseconds | 79 | * @resolution: the resolution of the clock, in nanoseconds |
80 | * @get_time: function to retrieve the current time of the clock | 80 | * @get_time: function to retrieve the current time of the clock |
81 | * @get_softirq_time: function to retrieve the current time from the softirq | 81 | * @get_softirq_time: function to retrieve the current time from the softirq |
82 | * @curr_timer: the timer which is executing a callback right now | ||
83 | * @softirq_time: the time when running the hrtimer queue in the softirq | 82 | * @softirq_time: the time when running the hrtimer queue in the softirq |
84 | * @lock_key: the lock_class_key for use with lockdep | ||
85 | */ | 83 | */ |
86 | struct hrtimer_base { | 84 | struct hrtimer_clock_base { |
85 | struct hrtimer_cpu_base *cpu_base; | ||
87 | clockid_t index; | 86 | clockid_t index; |
88 | spinlock_t lock; | ||
89 | struct rb_root active; | 87 | struct rb_root active; |
90 | struct rb_node *first; | 88 | struct rb_node *first; |
91 | ktime_t resolution; | 89 | ktime_t resolution; |
92 | ktime_t (*get_time)(void); | 90 | ktime_t (*get_time)(void); |
93 | ktime_t (*get_softirq_time)(void); | 91 | ktime_t (*get_softirq_time)(void); |
94 | struct hrtimer *curr_timer; | ||
95 | ktime_t softirq_time; | 92 | ktime_t softirq_time; |
96 | struct lock_class_key lock_key; | 93 | }; |
94 | |||
95 | #define HRTIMER_MAX_CLOCK_BASES 2 | ||
96 | |||
97 | /* | ||
98 | * struct hrtimer_cpu_base - the per cpu clock bases | ||
99 | * @lock: lock protecting the base and associated clock bases | ||
100 | * and timers | ||
101 | * @lock_key: the lock_class_key for use with lockdep | ||
102 | * @clock_base: array of clock bases for this cpu | ||
103 | * @curr_timer: the timer which is executing a callback right now | ||
104 | */ | ||
105 | struct hrtimer_cpu_base { | ||
106 | spinlock_t lock; | ||
107 | struct lock_class_key lock_key; | ||
108 | struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; | ||
109 | struct hrtimer *curr_timer; | ||
97 | }; | 110 | }; |
98 | 111 | ||
99 | /* | 112 | /* |