Re: [PATCH RFC 1/8] perf/core: Add *group_leader to perf_event_create_kernel_counter()

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

 



On Mon, 12 Dec 2022 12:58:37 +0000,
Like Xu <like.xu.linux@xxxxxxxxx> wrote:
> 
> From: Like Xu <likexu@xxxxxxxxxxx>
> 
> Like syscalls users, kernel-space perf_event creators may also use group
> counters abstraction to gain pmu functionalities, and an in-kernel counter
> groups behave much like normal 'single' counters, following the group
> semantics-based behavior.
> 
> No functional changes at this time. An example will be that KVM creates
> Intel slot event as group leader and other topdown metric events to emulate
> MSR_PERF_METRICS pmu capability for guests.
> 
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Marc Zyngier <maz@xxxxxxxxxx>
> Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> Cc: kvmarm@xxxxxxxxxxxxxxx
> Cc: linux-perf-users@xxxxxxxxxxxxxxx
> Signed-off-by: Like Xu <likexu@xxxxxxxxxxx>
> ---
>  arch/arm64/kvm/pmu-emul.c                 | 4 ++--
>  arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++--
>  arch/x86/kvm/pmu.c                        | 2 +-
>  arch/x86/kvm/vmx/pmu_intel.c              | 2 +-
>  include/linux/perf_event.h                | 1 +
>  kernel/events/core.c                      | 4 +++-
>  kernel/events/hw_breakpoint.c             | 4 ++--
>  kernel/events/hw_breakpoint_test.c        | 2 +-
>  kernel/watchdog_hld.c                     | 2 +-
>  9 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> index 24908400e190..11c3386bc86b 100644
> --- a/arch/arm64/kvm/pmu-emul.c
> +++ b/arch/arm64/kvm/pmu-emul.c
> @@ -624,7 +624,7 @@ static void kvm_pmu_create_perf_event(struct kvm_pmc *pmc)
>  
>  	attr.sample_period = compute_period(pmc, kvm_pmu_get_pmc_value(pmc));
>  
> -	event = perf_event_create_kernel_counter(&attr, -1, current,
> +	event = perf_event_create_kernel_counter(&attr, -1, current, NULL,
>  						 kvm_pmu_perf_overflow, pmc);

Wouldn't it be better to have a separate helper that takes the group leader
as a parameter, and reimplement perf_event_create_kernel_counter() in term
of this helper?

	M.

-- 
Without deviation from the norm, progress is not possible.



[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