Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2
xen
24197-x86-waitqueue_Because_we_have_per-cpu_sta...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 24197-x86-waitqueue_Because_we_have_per-cpu_stacks_we_must_wake_up_on_teh.patch of Package xen
changeset: 24197:ca92c4a8b31f user: Keir Fraser <keir@xen.org> date: Thu Nov 24 15:50:08 2011 +0000 files: xen/common/wait.c description: 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@xen.org> --- xen/common/wait.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) Index: xen-4.1.2-testing/xen/common/wait.c =================================================================== --- xen-4.1.2-testing.orig/xen/common/wait.c +++ xen-4.1.2-testing/xen/common/wait.c @@ -34,6 +34,8 @@ struct waitqueue_vcpu { */ void *esp; char *stack; + cpumask_t saved_affinity; + unsigned int wakeup_cpu; #endif }; @@ -106,9 +108,19 @@ void wake_up(struct waitqueue_head *wq) 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(); + 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 __prepare_to_wait(struct wai 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 @@ void check_wakeup_from_wait(void) 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; + 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),
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor