Re: [PATCH] KVM: VMX: Cache IA32_DEBUGCTL in memory

From: Wanpeng Li
Date: Wed Nov 29 2017 - 04:20:50 EST


2017-11-29 17:13 GMT+08:00 Paolo Bonzini <pbonzini@xxxxxxxxxx>:
> On 29/11/2017 09:51, Wanpeng Li wrote:
>> 2017-11-29 16:48 GMT+08:00 Paolo Bonzini <pbonzini@xxxxxxxxxx>:
>>> On 29/11/2017 07:07, Wanpeng Li wrote:
>>>> From: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
>>>>
>>>> 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.
>>>>
>>>> Suggested-by: Jim Mattson <jmattson@xxxxxxxxxx>
>>>> Cc: Jim Mattson <jmattson@xxxxxxxxxx>
>>>> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
>>>> Cc: Radim KrÄmÃÅ <rkrcmar@xxxxxxxxxx>
>>>> Signed-off-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>
>>>
>>> The update_debugctlmsr should stay in vmx_vcpu_run so that tracing
>>> features work correctly. However, the get_debugctlmsr indeed can be
>>
>> The tracing can't run except vCPU is schedule out, so why
>> update_debugctlmsr should stay in vmx_vcpu_run?
>
> For example your patch is disabling BTS (branch trace store) after the
> first vmexit, isn't it?

I see. Thanks for pointing out. :)

Regards,
Wanpeng Li