[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86/waitqueue: Because we have per-cpu stacks, we must wake up on teh
# HG changeset patch # User Keir Fraser <keir@xxxxxxx> # Date 1322149808 0 # Node ID ca92c4a8b31f2af73b18e4c7dae193d7ecb598b8 # Parent de4fe05fe887d8c8ae71022ccd40cc9991def1bf x86/waitqueue: Because we have per-cpu stacks, we must wake up on teh same cpu that we slept on. Otherwise stack references are bogus on wakeup. Signed-off-by: Keir Fraser <keir@xxxxxxx> --- diff -r de4fe05fe887 -r ca92c4a8b31f xen/common/wait.c --- a/xen/common/wait.c Thu Nov 24 15:49:25 2011 +0000 +++ b/xen/common/wait.c Thu Nov 24 15:50:08 2011 +0000 @@ -34,6 +34,8 @@ */ void *esp; char *stack; + cpumask_t saved_affinity; + unsigned int wakeup_cpu; #endif }; @@ -106,9 +108,19 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) { char *cpu_info = (char *)get_cpu_info(); + struct vcpu *curr = current; ASSERT(wqv->esp == 0); + /* Save current VCPU affinity; force wakeup on *this* CPU only. */ + wqv->wakeup_cpu = smp_processor_id(); + cpumask_copy(&wqv->saved_affinity, curr->cpu_affinity); + if ( vcpu_set_affinity(curr, cpumask_of(wqv->wakeup_cpu)) ) + { + gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); + domain_crash_synchronous(); + } + asm volatile ( #ifdef CONFIG_X86_64 "push %%rax; push %%rbx; push %%rcx; push %%rdx; push %%rdi; " @@ -144,6 +156,7 @@ static void __finish_wait(struct waitqueue_vcpu *wqv) { wqv->esp = NULL; + (void)vcpu_set_affinity(current, &wqv->saved_affinity); } void check_wakeup_from_wait(void) @@ -155,6 +168,20 @@ if ( likely(wqv->esp == NULL) ) return; + /* Check if we woke up on the wrong CPU. */ + if ( unlikely(smp_processor_id() != wqv->wakeup_cpu) ) + { + /* Re-set VCPU affinity and re-enter the scheduler. */ + struct vcpu *curr = current; + cpumask_copy(&wqv->saved_affinity, curr->cpu_affinity); + if ( vcpu_set_affinity(curr, cpumask_of(wqv->wakeup_cpu)) ) + { + gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); + domain_crash_synchronous(); + } + wait(); /* takes us back into the scheduler */ + } + asm volatile ( "mov %1,%%"__OP"sp; rep movsb; jmp *(%%"__OP"sp)" : : "S" (wqv->stack), "D" (wqv->esp), _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |