Skip to content

Commit f26f993

Browse files
kjain101mpe
authored andcommitted
powerpc/perf: Add per-task/process monitoring to vpa_pmu driver
Enhance the vpa_pmu driver with a feature to observe context switch latency event for both per-task (tid) and per-pid (pid) option. Couple of new helper functions are added to hide the abstraction of reading the context switch latency counter from kvm_vcpu_arch struct and these helper functions are defined in the "kvm/book3s_hv.c". "PERF_ATTACH_TASK" flag is used to decide whether to read the counter values from lppaca or kvm_vcpu_arch struct. Signed-off-by: Kajol Jain <[email protected]> Co-developed-by: Madhavan Srinivasan <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 5f0b48c commit f26f993

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

arch/powerpc/include/asm/kvm_book3s_64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,9 @@ void kvmhv_set_l2_counters_status(int cpu, bool status);
691691
u64 kvmhv_get_l1_to_l2_cs_time(void);
692692
u64 kvmhv_get_l2_to_l1_cs_time(void);
693693
u64 kvmhv_get_l2_runtime_agg(void);
694+
u64 kvmhv_get_l1_to_l2_cs_time_vcpu(void);
695+
u64 kvmhv_get_l2_to_l1_cs_time_vcpu(void);
696+
u64 kvmhv_get_l2_runtime_agg_vcpu(void);
694697

695698
#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
696699

arch/powerpc/kvm/book3s_hv.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,51 @@ u64 kvmhv_get_l2_runtime_agg(void)
41904190
}
41914191
EXPORT_SYMBOL(kvmhv_get_l2_runtime_agg);
41924192

4193+
u64 kvmhv_get_l1_to_l2_cs_time_vcpu(void)
4194+
{
4195+
struct kvm_vcpu *vcpu;
4196+
struct kvm_vcpu_arch *arch;
4197+
4198+
vcpu = local_paca->kvm_hstate.kvm_vcpu;
4199+
if (vcpu) {
4200+
arch = &vcpu->arch;
4201+
return arch->l1_to_l2_cs;
4202+
} else {
4203+
return 0;
4204+
}
4205+
}
4206+
EXPORT_SYMBOL(kvmhv_get_l1_to_l2_cs_time_vcpu);
4207+
4208+
u64 kvmhv_get_l2_to_l1_cs_time_vcpu(void)
4209+
{
4210+
struct kvm_vcpu *vcpu;
4211+
struct kvm_vcpu_arch *arch;
4212+
4213+
vcpu = local_paca->kvm_hstate.kvm_vcpu;
4214+
if (vcpu) {
4215+
arch = &vcpu->arch;
4216+
return arch->l2_to_l1_cs;
4217+
} else {
4218+
return 0;
4219+
}
4220+
}
4221+
EXPORT_SYMBOL(kvmhv_get_l2_to_l1_cs_time_vcpu);
4222+
4223+
u64 kvmhv_get_l2_runtime_agg_vcpu(void)
4224+
{
4225+
struct kvm_vcpu *vcpu;
4226+
struct kvm_vcpu_arch *arch;
4227+
4228+
vcpu = local_paca->kvm_hstate.kvm_vcpu;
4229+
if (vcpu) {
4230+
arch = &vcpu->arch;
4231+
return arch->l2_runtime_agg;
4232+
} else {
4233+
return 0;
4234+
}
4235+
}
4236+
EXPORT_SYMBOL(kvmhv_get_l2_runtime_agg_vcpu);
4237+
41934238
#else
41944239
int kvmhv_get_l2_counters_status(void)
41954240
{

arch/powerpc/perf/vpa-pmu.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,22 @@ static unsigned long get_counter_data(struct perf_event *event)
9797

9898
switch (config) {
9999
case L1_TO_L2_CS_LAT:
100-
data = kvmhv_get_l1_to_l2_cs_time();
100+
if (event->attach_state & PERF_ATTACH_TASK)
101+
data = kvmhv_get_l1_to_l2_cs_time_vcpu();
102+
else
103+
data = kvmhv_get_l1_to_l2_cs_time();
101104
break;
102105
case L2_TO_L1_CS_LAT:
103-
data = kvmhv_get_l2_to_l1_cs_time();
106+
if (event->attach_state & PERF_ATTACH_TASK)
107+
data = kvmhv_get_l2_to_l1_cs_time_vcpu();
108+
else
109+
data = kvmhv_get_l2_to_l1_cs_time();
104110
break;
105111
case L2_RUNTIME_AGG:
106-
data = kvmhv_get_l2_runtime_agg();
112+
if (event->attach_state & PERF_ATTACH_TASK)
113+
data = kvmhv_get_l2_runtime_agg_vcpu();
114+
else
115+
data = kvmhv_get_l2_runtime_agg();
107116
break;
108117
default:
109118
data = 0;

0 commit comments

Comments
 (0)