From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andi Kleen Subject: Re: [PATCH] KVM: VMX: Cache IA32_DEBUGCTL in memory Date: Wed, 29 Nov 2017 10:20:51 -0800 Message-ID: <87fu8xj69o.fsf@linux.intel.com> References: <1511935673-7371-1-git-send-email-wanpeng.li@hotmail.com> Mime-Version: 1.0 Content-Type: text/plain Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Wanpeng Li , Jim Mattson To: Wanpeng Li Return-path: In-Reply-To: <1511935673-7371-1-git-send-email-wanpeng.li@hotmail.com> (Wanpeng Li's message of "Tue, 28 Nov 2017 22:07:53 -0800") Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Wanpeng Li writes: > From: Wanpeng Li > > MSR_IA32_DEBUGCTLMSR is zeroed on VMEXIT, so it is saved/restored > each time during world switch. Jim from Google pointed out that > when running schbench in L2, vmx_vcpu_run will occupy 4% cpu time, > and the 25% of vmx_vcpu_run cpu time is occupied by get_debugctlmsr(). > This patch caches the host IA32_DEBUGCTL MSR and saves/restores > the host IA32_DEBUGCTL msr when guest/host switches to avoid to > save/restore each time during world switch. FWIW i've seen this too on L2 profiles. But I haven't looked too closely, but I suspect you'll clobber global kernel debugger state this way. You would at least need some interface for KDB etc. to invalidate your cache. -Andi