diff options
author | Richard Cochran <rcochran@linutronix.de> | 2016-07-13 13:16:52 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-15 04:40:28 -0400 |
commit | 4761adb6f49048cddd65553a71ea2354b2a838be (patch) | |
tree | 7ef757ce468242ac2a814f619ae63d713723de4e | |
parent | 26b8768868c090151aa8c337773d429e0d5ca727 (diff) |
arm/xen: Convert to hotplug state machine
Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
The get_cpu() in xen_starting_cpu() boils down to preempt_disable() since
we already know the CPU we run on. Disabling preemption shouldn't be required
here from what I see since it we don't switch CPUs while invoking the function.
Signed-off-by: Richard Cochran <rcochran@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: rt@linutronix.de
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/20160713153336.971559670@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/arm/xen/enlighten.c | 41 | ||||
-rw-r--r-- | include/linux/cpuhotplug.h | 1 |
2 files changed, 12 insertions, 30 deletions
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 75cd7345c654..d822e2313950 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c | |||
@@ -161,12 +161,11 @@ static struct notifier_block xen_pvclock_gtod_notifier = { | |||
161 | .notifier_call = xen_pvclock_gtod_notify, | 161 | .notifier_call = xen_pvclock_gtod_notify, |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static void xen_percpu_init(void) | 164 | static int xen_starting_cpu(unsigned int cpu) |
165 | { | 165 | { |
166 | struct vcpu_register_vcpu_info info; | 166 | struct vcpu_register_vcpu_info info; |
167 | struct vcpu_info *vcpup; | 167 | struct vcpu_info *vcpup; |
168 | int err; | 168 | int err; |
169 | int cpu = get_cpu(); | ||
170 | 169 | ||
171 | /* | 170 | /* |
172 | * VCPUOP_register_vcpu_info cannot be called twice for the same | 171 | * VCPUOP_register_vcpu_info cannot be called twice for the same |
@@ -190,7 +189,13 @@ static void xen_percpu_init(void) | |||
190 | 189 | ||
191 | after_register_vcpu_info: | 190 | after_register_vcpu_info: |
192 | enable_percpu_irq(xen_events_irq, 0); | 191 | enable_percpu_irq(xen_events_irq, 0); |
193 | put_cpu(); | 192 | return 0; |
193 | } | ||
194 | |||
195 | static int xen_dying_cpu(unsigned int cpu) | ||
196 | { | ||
197 | disable_percpu_irq(xen_events_irq); | ||
198 | return 0; | ||
194 | } | 199 | } |
195 | 200 | ||
196 | static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) | 201 | static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) |
@@ -209,28 +214,6 @@ static void xen_power_off(void) | |||
209 | BUG_ON(rc); | 214 | BUG_ON(rc); |
210 | } | 215 | } |
211 | 216 | ||
212 | static int xen_cpu_notification(struct notifier_block *self, | ||
213 | unsigned long action, | ||
214 | void *hcpu) | ||
215 | { | ||
216 | switch (action) { | ||
217 | case CPU_STARTING: | ||
218 | xen_percpu_init(); | ||
219 | break; | ||
220 | case CPU_DYING: | ||
221 | disable_percpu_irq(xen_events_irq); | ||
222 | break; | ||
223 | default: | ||
224 | break; | ||
225 | } | ||
226 | |||
227 | return NOTIFY_OK; | ||
228 | } | ||
229 | |||
230 | static struct notifier_block xen_cpu_notifier = { | ||
231 | .notifier_call = xen_cpu_notification, | ||
232 | }; | ||
233 | |||
234 | static irqreturn_t xen_arm_callback(int irq, void *arg) | 217 | static irqreturn_t xen_arm_callback(int irq, void *arg) |
235 | { | 218 | { |
236 | xen_hvm_evtchn_do_upcall(); | 219 | xen_hvm_evtchn_do_upcall(); |
@@ -351,16 +334,14 @@ static int __init xen_guest_init(void) | |||
351 | return -EINVAL; | 334 | return -EINVAL; |
352 | } | 335 | } |
353 | 336 | ||
354 | xen_percpu_init(); | ||
355 | |||
356 | register_cpu_notifier(&xen_cpu_notifier); | ||
357 | |||
358 | pv_time_ops.steal_clock = xen_stolen_accounting; | 337 | pv_time_ops.steal_clock = xen_stolen_accounting; |
359 | static_key_slow_inc(¶virt_steal_enabled); | 338 | static_key_slow_inc(¶virt_steal_enabled); |
360 | if (xen_initial_domain()) | 339 | if (xen_initial_domain()) |
361 | pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); | 340 | pvclock_gtod_register_notifier(&xen_pvclock_gtod_notifier); |
362 | 341 | ||
363 | return 0; | 342 | return cpuhp_setup_state(CPUHP_AP_ARM_XEN_STARTING, |
343 | "AP_ARM_XEN_STARTING", xen_starting_cpu, | ||
344 | xen_dying_cpu); | ||
364 | } | 345 | } |
365 | early_initcall(xen_guest_init); | 346 | early_initcall(xen_guest_init); |
366 | 347 | ||
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index ad48881ba02d..4c02b52dc77f 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h | |||
@@ -47,6 +47,7 @@ enum cpuhp_state { | |||
47 | CPUHP_AP_KVM_STARTING, | 47 | CPUHP_AP_KVM_STARTING, |
48 | CPUHP_AP_KVM_ARM_VGIC_STARTING, | 48 | CPUHP_AP_KVM_ARM_VGIC_STARTING, |
49 | CPUHP_AP_KVM_ARM_TIMER_STARTING, | 49 | CPUHP_AP_KVM_ARM_TIMER_STARTING, |
50 | CPUHP_AP_ARM_XEN_STARTING, | ||
50 | CPUHP_AP_LEDTRIG_STARTING, | 51 | CPUHP_AP_LEDTRIG_STARTING, |
51 | CPUHP_AP_NOTIFY_STARTING, | 52 | CPUHP_AP_NOTIFY_STARTING, |
52 | CPUHP_AP_ONLINE, | 53 | CPUHP_AP_ONLINE, |