From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: VMX: Do not overwrite vcpu->srcu_idx in vmx_vcpu_reset Date: Thu, 14 Mar 2013 16:45:23 +0100 Message-ID: <5141F093.1020001@redhat.com> References: <5141E41B.8080804@siemens.com> <20130314150004.GX11223@redhat.com> <5141E6BA.2060404@siemens.com> <5141E7FA.8060003@redhat.com> <20130314151106.GA15717@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Marcelo Tosatti , kvm To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65337 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755850Ab3CNPp1 (ORCPT ); Thu, 14 Mar 2013 11:45:27 -0400 In-Reply-To: <20130314151106.GA15717@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 14/03/2013 16:11, Gleb Natapov ha scritto: > On Thu, Mar 14, 2013 at 04:08:42PM +0100, Paolo Bonzini wrote: >> Il 14/03/2013 16:03, Jan Kiszka ha scritto: >>>>> vcpu->srcu_idx = srcu_read_lock() >>>>> idx = srcu_read_lock(&vcpu->kvm->srcu); >>>>> srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >>>>> vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >>>>> srcu_read_unlock(&vcpu->kvm->srcu, idx); >>>>> srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >>>>> >>>>> Not sure this is valid. >>> Grmbl, likely not. >> >> It might be. >> >> Isn't it the same as two different CPUs doing >> >> CPU 1 CPU 2 >> ------------------------------------------------------------------------------------------------ >> >> vcpu->srcu_idx = srcu_read_lock() >> idx = srcu_read_lock(&vcpu->kvm->srcu); >> srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); >> srcu_read_unlock(&vcpu->kvm->srcu, idx); >> srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); >> >> ? >> > Srcu may have per cpu state. We can always ask Paul. There is per-CPU state but it is only used as an optimization. synchronize_srcu only uses the sum of all values. In fact, SRCU critical sections are preemptable so there's not even a guarantee that srcu_read_lock() and srcu_read_unlock() run on the same CPU. Paolo