question about arch/s390/kvm/interrupt.c
In a recent version of linux-next, the function kvm_s390_handle_wait contains the following code:
add_wait_queue(&vcpu->arch.local_int.wq, &wait);
while (list_empty(&vcpu->arch.local_int.list) &&
list_empty(&vcpu->arch.local_int.float_int->list) &&
(!vcpu->arch.local_int.timer_due) &&
!signal_pending(current)) {
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_bh(&vcpu->arch.local_int.lock);
spin_unlock(&vcpu->arch.local_int.float_int->lock);
vcpu_put(vcpu);
schedule();
vcpu_load(vcpu);
spin_lock(&vcpu->arch.local_int.float_int->lock);
spin_lock_bh(&vcpu->arch.local_int.lock);
}
__unset_cpu_idle(vcpu);
__set_current_state(TASK_RUNNING);
remove_wait_queue(&vcpu->wq, &wait);It seems a bit odd that the first argument to add_wait queue is &vcpu->arch.local_int.wq but the first argument to remove_wait_queue is &vcpu->wq. I don't see any obvious evidence that they are the same thing, but perhaps I am missing something. Should either call be changed?
julia
(copying some s390 people)
Quoted 28 lines · Julia Lawall
In a recent version of linux-next, the function
kvm_s390_handle_waitcontains the following code:add_wait_queue(&vcpu->arch.local_int.wq,&wait); while (list_empty(&vcpu->arch.local_int.list)&& list_empty(&vcpu->arch.local_int.float_int->list)&& (!vcpu->arch.local_int.timer_due)&& !signal_pending(current)) { set_current_state(TASK_INTERRUPTIBLE); spin_unlock_bh(&vcpu->arch.local_int.lock); spin_unlock(&vcpu->arch.local_int.float_int->lock); vcpu_put(vcpu); schedule(); vcpu_load(vcpu); spin_lock(&vcpu->arch.local_int.float_int->lock); spin_lock_bh(&vcpu->arch.local_int.lock); } __unset_cpu_idle(vcpu); __set_current_state(TASK_RUNNING); remove_wait_queue(&vcpu->wq,&wait);It seems a bit odd that the first argument to
add_waitqueue is&vcpu->arch.local_int.wqbut the first argument toremove_wait_queueis&vcpu->wq. I don't see any obvious evidence that they are the same thing, but perhaps I am missing something. Should either call be changed?julia
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 28 lines
(copying some s390 people)
Quoted 25 lines · Julia Lawall
In a recent version of linux-next, the function
kvm_s390_handle_waitcontains the following code:add_wait_queue(&vcpu->arch.local_int.wq,&wait); while (list_empty(&vcpu->arch.local_int.list)&& list_empty(&vcpu->arch.local_int.float_int->list)&& (!vcpu->arch.local_int.timer_due)&& !signal_pending(current)) { set_current_state(TASK_INTERRUPTIBLE); spin_unlock_bh(&vcpu->arch.local_int.lock); spin_unlock(&vcpu->arch.local_int.float_int->lock); vcpu_put(vcpu); schedule(); vcpu_load(vcpu); spin_lock(&vcpu->arch.local_int.float_int->lock); spin_lock_bh(&vcpu->arch.local_int.lock); } __unset_cpu_idle(vcpu); __set_current_state(TASK_RUNNING); remove_wait_queue(&vcpu->wq,&wait);It seems a bit odd that the first argument to
add_waitqueue is&vcpu->arch.local_int.wqbut the first argument toremove_wait_queueis&vcpu->wq. I don't see any obvious evidence that they are the same thing, but perhaps I am missing something. Should either call be changed?
Good catch! It's broken, I'll send a fix later today.
so long,
Carsten
PATCH 1/1 kvm-390: fix wait_queue handling
In reply to Avi KivityFrom: Christian Borntraeger <[email protected]>
There are two waitqueues in kvm for wait handling:vcpu->wq for virt/kvm/kvm_main.c and vpcu->arch.local_int.wq for the s390 specific wait code.
the wait handling in kvm_s390_handle_wait was broken by using different wait_queues for add_wait queue and remove_wait_queue.
There are two options to fix the problem:
o move all the s390 specific code to vcpu->wq and remove vcpu->arch.local_int.wq
o move all the s390 specific code to vcpu->arch.local_int.wq
This patch chooses the 2nd variant for two reasons:
o s390 does not use kvm_vcpu_block but implements its own enabled wait handling.
Having a separate wait_queue make it clear, that our wait mechanism is different
o the patch is much smaller
--- arch/s390/kvm/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/interrupt.c +1 -1
@@ -386,7 +386,7 @@ no_timer: }__unset_cpu_idle (vcpu);__set_current_state (TASK_RUNNING ); -remove_wait_queue (&vcpu->wq, &wait); +remove_wait_queue (&vcpu->arch.local_int.wq, &wait);spin_unlock_bh (&vcpu->arch.local_int.lock);spin_unlock (&vcpu->arch.local_int.float_int->lock);hrtimer_try_to_cancel (&vcpu->arch.ckc_timer);
Marcelo Tosatti
AppliedRe: [PATCH] kvm-390: fix wait_queue handling
Quoted 32 lines · Christian Bornträger
From: Christian Borntraeger <[email protected]>
There are two waitqueues in kvm for wait handling:
vcpu->wqforvirt/kvm/kvm_main.candvpcu->arch.local_int.wqfor the s390 specific wait code.the wait handling in
kvm_s390_handle_waitwas broken by using differentwait_queuesforadd_waitqueue andremove_wait_queue.There are two options to fix the problem:
o move all the s390 specific code tovcpu->wqand removevcpu->arch.local_int.wq
o move all the s390 specific code tovcpu->arch.local_int.wqThis patch chooses the 2nd variant for two reasons:
o s390 does not usekvm_vcpu_blockbut implements its own enabled wait handling.
Having a separatewait_queuemake it clear, that our wait mechanism is different
o the patch is much smallerReport-by Julia Lawall <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
kvm/arch/s390/kvm/interrupt.c
===================================================================
arch/s390/kvm/interrupt.c no_timer: · line 392
Quoted 8 lines
arch/s390/kvm/interrupt.c +1
-1@@ -386,7 +386,7 @@ no_timer: }__unset_cpu_idle (vcpu);__set_current_state (TASK_RUNNING ); -remove_wait_queue (&vcpu->wq, &wait); +remove_wait_queue (&vcpu->arch.local_int.wq, &wait);spin_unlock_bh (&vcpu->arch.local_int.lock);spin_unlock (&vcpu->arch.local_int.float_int->lock);hrtimer_try_to_cancel (&vcpu->arch.ckc_timer);
Applied, thanks.