Re: [PATCH v9 4/5] KVM: arm/arm64: remove pmc->bitmask

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

 





On 13/06/2019 10:39, Andrew Murray wrote:
On Thu, Jun 13, 2019 at 08:30:51AM +0100, Julien Thierry wrote:
Hi Andrew,

On 12/06/2019 20:04, Andrew Murray wrote:
We currently use pmc->bitmask to determine the width of the pmc - however
it's superfluous as the pmc index already describes if the pmc is a cycle
counter or event counter. The architecture clearly describes the widths of
these counters.

Let's remove the bitmask to simplify the code.

Signed-off-by: Andrew Murray <andrew.murray@xxxxxxx>
---
  include/kvm/arm_pmu.h |  1 -
  virt/kvm/arm/pmu.c    | 19 +++++++++----------
  2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h
index b73f31baca52..2f0e28dc5a9e 100644
--- a/include/kvm/arm_pmu.h
+++ b/include/kvm/arm_pmu.h
@@ -28,7 +28,6 @@
  struct kvm_pmc {
  	u8 idx;	/* index into the pmu->pmc array */
  	struct perf_event *perf_event;
-	u64 bitmask;
  };
struct kvm_pmu {
diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index ae1e886d4a1a..88ce24ae0b45 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -47,7 +47,10 @@ u64 kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu, u64 select_idx)
  		counter += perf_event_read_value(pmc->perf_event, &enabled,
  						 &running);
- return counter & pmc->bitmask;
+	if (select_idx != ARMV8_PMU_CYCLE_IDX)
+		counter = lower_32_bits(counter);

Shouldn't this depend on PMCR.LC as well? If PMCR.LC is clear we only
want the lower 32bits of the cycle counter.

Yes that's correct. The hunk should look like this:

-       return counter & pmc->bitmask;
+       if (!(select_idx == ARMV8_PMU_CYCLE_IDX &&
+             __vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_LC))
+               counter = lower_32_bits(counter);
+
+       return counter;

May be you could add a macro :

#define vcpu_pmu_counter_is_64bit(vcpu, idx) ?

Cheers
Suzuki
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux