diff options
Diffstat (limited to 'arch/x86/kernel/process.c')
-rw-r--r-- | arch/x86/kernel/process.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index c622772744d8..e68bb9e30864 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -1,13 +1,16 @@ | |||
1 | #include <linux/errno.h> | 1 | #include <linux/errno.h> |
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/mm.h> | 3 | #include <linux/mm.h> |
4 | #include <asm/idle.h> | ||
4 | #include <linux/smp.h> | 5 | #include <linux/smp.h> |
5 | #include <linux/slab.h> | 6 | #include <linux/slab.h> |
6 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
7 | #include <linux/module.h> | 8 | #include <linux/module.h> |
8 | #include <linux/pm.h> | 9 | #include <linux/pm.h> |
9 | #include <linux/clockchips.h> | 10 | #include <linux/clockchips.h> |
11 | #include <linux/ftrace.h> | ||
10 | #include <asm/system.h> | 12 | #include <asm/system.h> |
13 | #include <asm/apic.h> | ||
11 | 14 | ||
12 | unsigned long idle_halt; | 15 | unsigned long idle_halt; |
13 | EXPORT_SYMBOL(idle_halt); | 16 | EXPORT_SYMBOL(idle_halt); |
@@ -100,6 +103,9 @@ static inline int hlt_use_halt(void) | |||
100 | void default_idle(void) | 103 | void default_idle(void) |
101 | { | 104 | { |
102 | if (hlt_use_halt()) { | 105 | if (hlt_use_halt()) { |
106 | struct power_trace it; | ||
107 | |||
108 | trace_power_start(&it, POWER_CSTATE, 1); | ||
103 | current_thread_info()->status &= ~TS_POLLING; | 109 | current_thread_info()->status &= ~TS_POLLING; |
104 | /* | 110 | /* |
105 | * TS_POLLING-cleared state must be visible before we | 111 | * TS_POLLING-cleared state must be visible before we |
@@ -112,6 +118,7 @@ void default_idle(void) | |||
112 | else | 118 | else |
113 | local_irq_enable(); | 119 | local_irq_enable(); |
114 | current_thread_info()->status |= TS_POLLING; | 120 | current_thread_info()->status |= TS_POLLING; |
121 | trace_power_end(&it); | ||
115 | } else { | 122 | } else { |
116 | local_irq_enable(); | 123 | local_irq_enable(); |
117 | /* loop is done by the caller */ | 124 | /* loop is done by the caller */ |
@@ -122,6 +129,21 @@ void default_idle(void) | |||
122 | EXPORT_SYMBOL(default_idle); | 129 | EXPORT_SYMBOL(default_idle); |
123 | #endif | 130 | #endif |
124 | 131 | ||
132 | void stop_this_cpu(void *dummy) | ||
133 | { | ||
134 | local_irq_disable(); | ||
135 | /* | ||
136 | * Remove this CPU: | ||
137 | */ | ||
138 | cpu_clear(smp_processor_id(), cpu_online_map); | ||
139 | disable_local_APIC(); | ||
140 | |||
141 | for (;;) { | ||
142 | if (hlt_works(smp_processor_id())) | ||
143 | halt(); | ||
144 | } | ||
145 | } | ||
146 | |||
125 | static void do_nothing(void *unused) | 147 | static void do_nothing(void *unused) |
126 | { | 148 | { |
127 | } | 149 | } |
@@ -154,24 +176,31 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); | |||
154 | */ | 176 | */ |
155 | void mwait_idle_with_hints(unsigned long ax, unsigned long cx) | 177 | void mwait_idle_with_hints(unsigned long ax, unsigned long cx) |
156 | { | 178 | { |
179 | struct power_trace it; | ||
180 | |||
181 | trace_power_start(&it, POWER_CSTATE, (ax>>4)+1); | ||
157 | if (!need_resched()) { | 182 | if (!need_resched()) { |
158 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 183 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
159 | smp_mb(); | 184 | smp_mb(); |
160 | if (!need_resched()) | 185 | if (!need_resched()) |
161 | __mwait(ax, cx); | 186 | __mwait(ax, cx); |
162 | } | 187 | } |
188 | trace_power_end(&it); | ||
163 | } | 189 | } |
164 | 190 | ||
165 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ | 191 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ |
166 | static void mwait_idle(void) | 192 | static void mwait_idle(void) |
167 | { | 193 | { |
194 | struct power_trace it; | ||
168 | if (!need_resched()) { | 195 | if (!need_resched()) { |
196 | trace_power_start(&it, POWER_CSTATE, 1); | ||
169 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 197 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
170 | smp_mb(); | 198 | smp_mb(); |
171 | if (!need_resched()) | 199 | if (!need_resched()) |
172 | __sti_mwait(0, 0); | 200 | __sti_mwait(0, 0); |
173 | else | 201 | else |
174 | local_irq_enable(); | 202 | local_irq_enable(); |
203 | trace_power_end(&it); | ||
175 | } else | 204 | } else |
176 | local_irq_enable(); | 205 | local_irq_enable(); |
177 | } | 206 | } |
@@ -183,9 +212,13 @@ static void mwait_idle(void) | |||
183 | */ | 212 | */ |
184 | static void poll_idle(void) | 213 | static void poll_idle(void) |
185 | { | 214 | { |
215 | struct power_trace it; | ||
216 | |||
217 | trace_power_start(&it, POWER_CSTATE, 0); | ||
186 | local_irq_enable(); | 218 | local_irq_enable(); |
187 | while (!need_resched()) | 219 | while (!need_resched()) |
188 | cpu_relax(); | 220 | cpu_relax(); |
221 | trace_power_end(&it); | ||
189 | } | 222 | } |
190 | 223 | ||
191 | /* | 224 | /* |
@@ -270,7 +303,7 @@ static void c1e_idle(void) | |||
270 | rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi); | 303 | rdmsr(MSR_K8_INT_PENDING_MSG, lo, hi); |
271 | if (lo & K8_INTP_C1E_ACTIVE_MASK) { | 304 | if (lo & K8_INTP_C1E_ACTIVE_MASK) { |
272 | c1e_detected = 1; | 305 | c1e_detected = 1; |
273 | if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) | 306 | if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) |
274 | mark_tsc_unstable("TSC halt in AMD C1E"); | 307 | mark_tsc_unstable("TSC halt in AMD C1E"); |
275 | printk(KERN_INFO "System has AMD C1E enabled\n"); | 308 | printk(KERN_INFO "System has AMD C1E enabled\n"); |
276 | set_cpu_cap(&boot_cpu_data, X86_FEATURE_AMDC1E); | 309 | set_cpu_cap(&boot_cpu_data, X86_FEATURE_AMDC1E); |