On 2025-05-20 1:51 p.m., Namhyung Kim wrote:
>>>> @@ -1089,6 +1094,7 @@ struct bpf_perf_event_data_kern {
>>>>   */
>>>>  struct perf_cgroup_info {
>>>>    struct perf_time_ctx            time;
>>>> +  struct perf_time_ctx            timeguest;
>>>>    int                             active;
>>>>  };
>>>>  
>>>> diff --git a/kernel/events/core.c b/kernel/events/core.c
>>>> index e38c8b5e8086..7a2115b2c5c1 100644
>>>> --- a/kernel/events/core.c
>>>> +++ b/kernel/events/core.c
>>>> @@ -163,7 +163,8 @@ enum event_type_t {
>>>>    /* see ctx_resched() for details */
>>>>    EVENT_CPU       = 0x10,
>>>>    EVENT_CGROUP    = 0x20,
>>>> -  EVENT_FLAGS     = EVENT_CGROUP,
>>>> +  EVENT_GUEST     = 0x40,
>>> It's not clear to me if this flag is for events to include guests or
>>> exclude them.  Can you please add a comment?
>>>
>> /*
>>  * There are guest events. The for_each_epc() iteration can
>>  * skip those PMUs which doesn't support guest events via the
>>  * MEDIATED_VPMU. It is also used to indicate the start/end of
>>  * guest events to calculate the guest running time.
>>  */
> Thanks for the explanation.  So it's for events with !exclude_guest on
> host 

The above "guest events" means that the events in a guest. The KVM
should only invokes the interface when a guest requires PMU.

For the host, for now, only the event with exclude_guest is supported.
The !exclude_guest event on host must be failed to be created if there
is a running VM.

and to do some operation only for host-only events on mediated
> vPMUs.

Yes.

Update the comments as below.

/*
 * There are events in a guest enabled with MEDIATED_VPMU.
 * The flag can be used in two places.
 * - The for_each_epc() iteration can skip those PMUs which
 *   doesn't support the events in a guest via the MEDIATED_VPMU.
 * - Indicate the start/end point of the events in a guest.
 *   The guest running time can be deducted for the
 *   host-only (exclude_guest) events.
 */

Thanks,
Kan

Reply via email to