From d2bbb28a22fa5e8fbaab0e37f3b4cddb49507c02 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 5 Jan 2009 11:29:42 +0000 Subject: [PATCH] evtchn: Fix CPU offlining to switch all affected ports belonging to a particular /dev/evcthn user. Original patch by James Harper Signed-off-by: Keir Fraser --- drivers/xen/evtchn/evtchn.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/xen/evtchn/evtchn.c b/drivers/xen/evtchn/evtchn.c index f814a8f8..051d5e4e 100644 --- a/drivers/xen/evtchn/evtchn.c +++ b/drivers/xen/evtchn/evtchn.c @@ -497,20 +497,22 @@ static int __cpuinit evtchn_cpu_notify(struct notifier_block *nfb, { int hotcpu = (unsigned long)hcpu; cpumask_t map = cpu_online_map; - int port, newcpu; + int i, j, newcpu; struct per_user_data *u; switch (action) { case CPU_DOWN_PREPARE: cpu_clear(hotcpu, map); spin_lock_irq(&port_user_lock); - for (port = 0; port < NR_EVENT_CHANNELS; port++) { - if ((u = port_user[port]) != NULL && - u->bind_cpu == hotcpu && - (newcpu = next_bind_cpu(map)) < NR_CPUS) { - rebind_evtchn_to_cpu(port, newcpu); - u->bind_cpu = newcpu; - } + for (i = 0; i < NR_EVENT_CHANNELS; i++) { + u = port_user[i]; + if ((u == NULL) || (u->bind_cpu != hotcpu)) + continue; + newcpu = next_bind_cpu(map); + for (j = i; j < NR_EVENT_CHANNELS; j++) + if (port_user[j] == u) + rebind_evtchn_to_cpu(j, newcpu); + u->bind_cpu = newcpu; } spin_unlock_irq(&port_user_lock); break; -- 2.39.5