Re: [PATCH v1 01/11] perf/x86/core: Support KVM to assign a dedicated counter for guest PEBS

From: Liang, Kan
Date: Fri Mar 06 2020 - 09:43:08 EST




On 3/6/2020 8:53 AM, Peter Zijlstra wrote:
On Fri, Mar 06, 2020 at 01:56:55AM +0800, Luwei Kang wrote:
From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>

The PEBS event created by host needs to be assigned specific counters
requested by the guest, which means the guest and host counter indexes
have to be the same or fail to create. This is needed because PEBS leaks
counter indexes into the guest. Otherwise, the guest driver will be
confused by the counter indexes in the status field of the PEBS record.

A guest_dedicated_idx field is added to indicate the counter index
specifically requested by KVM. The dedicated event constraints would
constrain the counter in the host to the same numbered counter in guest.

A intel_ctrl_guest_dedicated_mask field is added to indicate the enabled
counters for guest PEBS events. The IA32_PEBS_ENABLE MSR will be switched
during the VMX transitions if intel_ctrl_guest_owned is set.


+ /* the guest specified counter index of KVM owned event, e.g PEBS */
+ int guest_dedicated_idx;

We've always objected to guest 'owned' counters, they destroy scheduling
freedom. Why are you expecting that to be any different this time?


The new proposal tries to 'own' a counter by setting the event constraint. It doesn't stop other events using the counter.
If there is high priority event which requires the same counter, scheduler can still reject the request from KVM.
I don't think it destroys the scheduling freedom this time.

Thanks,
Kan