From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Rdl-0006kk-M9 for qemu-devel@nongnu.org; Sun, 28 Jul 2013 10:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Rdd-00037k-3Z for qemu-devel@nongnu.org; Sun, 28 Jul 2013 10:08:05 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:43162) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Rdc-00037W-SZ for qemu-devel@nongnu.org; Sun, 28 Jul 2013 10:07:56 -0400 Received: by mail-wi0-f175.google.com with SMTP id hq12so654606wib.2 for ; Sun, 28 Jul 2013 07:07:56 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51F525A9.7030503@redhat.com> Date: Sun, 28 Jul 2013 16:07:37 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1374764722-10685-1-git-send-email-pbonzini@redhat.com> <1374764722-10685-3-git-send-email-pbonzini@redhat.com> <20130728125745.GA27246@redhat.com> <51F521DD.5010308@redhat.com> <20130728135456.GJ11772@redhat.com> In-Reply-To: <20130728135456.GJ11772@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/2] kvm: migrate vPMU state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org, afaerber@suse.de, ehabkost@redhat.com Il 28/07/2013 15:54, Gleb Natapov ha scritto: > On Sun, Jul 28, 2013 at 03:51:25PM +0200, Paolo Bonzini wrote: >> Il 28/07/2013 14:57, Gleb Natapov ha scritto: >>>> @@ -1114,6 +1135,33 @@ static int kvm_put_msrs(X86CPU *cpu, int level) >>>> kvm_msr_entry_set(&msrs[n++], MSR_KVM_STEAL_TIME, >>>> env->steal_time_msr); >>>> } >>>> + if (has_msr_architectural_pmu) { >>>> + /* Stop the counter. */ >>>> + kvm_msr_entry_set(&msrs[n++], MSR_CORE_PERF_FIXED_CTR_CTRL, 0); >>>> + kvm_msr_entry_set(&msrs[n++], MSR_CORE_PERF_GLOBAL_CTRL, 0); >>>> + >>> Why is this needed? >> >> In v1 it was in the commit message. I'll fix it up before applying: >> >>> Second, to avoid any possible side effects during the setting of MSRs >>> I stop the PMU while setting the counters and event selector MSRs. >>> Stopping the PMU snapshots the counters and ensures that no strange >>> races can happen if the counters were saved close to their overflow >>> value. >> > Since vcpu is not running counters should not count anyway. Does the perf event distinguish KVM_RUN from any other activity in the vCPU thread (in which this code runs)? It seemed unsafe to me to change the overflow status and the performance counter value while the counter could be running, since the counter value could affect the overflow status. Maybe I was being paranoid? Paolo