Re: [RFC PATCH v3 15/58] perf/x86: Support switch_interrupt interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/25/2024 3:45 AM, Chen, Zide wrote:
>
> On 9/9/2024 3:11 PM, Colton Lewis wrote:
>> Mingwei Zhang <mizhang@xxxxxxxxxx> writes:
>>
>>> From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>>> Implement switch_interrupt interface for x86 PMU, switch PMI to dedicated
>>> KVM_GUEST_PMI_VECTOR at perf guest enter, and switch PMI back to
>>> NMI at perf guest exit.
>>> Signed-off-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxxxxxxxx>
>>> Signed-off-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
>>> Tested-by: Yongwei Ma <yongwei.ma@xxxxxxxxx>
>>> Signed-off-by: Mingwei Zhang <mizhang@xxxxxxxxxx>
>>> ---
>>>   arch/x86/events/core.c | 11 +++++++++++
>>>   1 file changed, 11 insertions(+)
>>> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
>>> index 5bf78cd619bf..b17ef8b6c1a6 100644
>>> --- a/arch/x86/events/core.c
>>> +++ b/arch/x86/events/core.c
>>> @@ -2673,6 +2673,15 @@ static bool x86_pmu_filter(struct pmu *pmu, int
>>> cpu)
>>>       return ret;
>>>   }
>>> +static void x86_pmu_switch_interrupt(bool enter, u32 guest_lvtpc)
>>> +{
>>> +    if (enter)
>>> +        apic_write(APIC_LVTPC, APIC_DM_FIXED | KVM_GUEST_PMI_VECTOR |
>>> +               (guest_lvtpc & APIC_LVT_MASKED));
>>> +    else
>>> +        apic_write(APIC_LVTPC, APIC_DM_NMI);
>>> +}
>>> +
>> Similar issue I point out in an earlier patch. #define
>> KVM_GUEST_PMI_VECTOR is guarded by CONFIG_KVM but this code is not,
>> which can result in compile errors.
> Since KVM_GUEST_PMI_VECTOR and the interrupt handler are owned by KVM,
> how about to simplify it to:
>
> static void x86_pmu_switch_guest_ctx(bool enter, void *data)
> {
> 	if (enter)
> 		apic_write(APIC_LVTPC, *(u32 *)data);
>         ...
> }
>
> In KVM side:
> perf_guest_enter(whatever_lvtpc_value_it_decides);

Good point. Would address in v4.


>
>
>>>   static struct pmu pmu = {
>>>       .pmu_enable        = x86_pmu_enable,
>>>       .pmu_disable        = x86_pmu_disable,
>>> @@ -2702,6 +2711,8 @@ static struct pmu pmu = {
>>>       .aux_output_match    = x86_pmu_aux_output_match,
>>>       .filter            = x86_pmu_filter,
>>> +
>>> +    .switch_interrupt    = x86_pmu_switch_interrupt,
>>>   };
>>>   void arch_perf_update_userpage(struct perf_event *event,




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux