From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: kvm_vcpu_block task state race Date: Fri, 09 May 2008 10:40:47 +0300 Message-ID: <4823FFFF.3040005@qumranet.com> References: <20080508224701.GA6175@dmt> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Marcelo Tosatti Return-path: In-Reply-To: <20080508224701.GA6175@dmt> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Marcelo Tosatti wrote: > There's still a race in kvm_vcpu_block(), if a wake_up_interruptible() > call happens before the task state is set to TASK_INTERRUPTIBLE: > > CPU0 CPU1 > > kvm_vcpu_block > > add_wait_queue > > kvm_cpu_has_interrupt = 0 > set interrupt > if (waitqueue_active()) > wake_up_interruptible() > > kvm_cpu_has_pending_timer > kvm_arch_vcpu_runnable > signal_pending > > set_current_state(TASK_INTERRUPTIBLE) > schedule() > > Can be fixed by using prepare_to_wait() which sets the task state before > testing for the wait condition. > > Unfortunately it can't use wait_event_interruptible() due to > vcpu_put/vcpu_load. > > schedule() will call vcpu_put()/vcpu_load() for us through preempt notifiers. I feel a little uneasy about it, but no concreate reason why not to rely on it. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone