kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: andrew.murray@arm.com, marc.zyngier@arm.com
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH v8 5/6] KVM: arm/arm64: remove pmc->bitmask
Date: Mon, 10 Jun 2019 13:54:35 +0100	[thread overview]
Message-ID: <036304c6-d5a8-5b36-48e1-1e919c55fc4c@arm.com> (raw)
In-Reply-To: <20190522162608.GF8268@e119886-lin.cambridge.arm.com>



On 22/05/2019 17:26, Andrew Murray wrote:
> On Wed, May 22, 2019 at 05:07:31PM +0100, Marc Zyngier wrote:
>> On 22/05/2019 16:30, 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@arm.com>
>>> ---
>>>   include/kvm/arm_pmu.h |  1 -
>>>   virt/kvm/arm/pmu.c    | 15 +++++----------
>>>   2 files changed, 5 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;
>>>   };
>>>   


>>> -
>>> -	if (val & ARMV8_PMU_PMCR_LC) {
>>> -		pmc = &pmu->pmc[ARMV8_PMU_CYCLE_IDX];
>>> -		pmc->bitmask = 0xffffffffffffffffUL;
>>> -	}
>>>   }

...

>>>   
>>>   static bool kvm_pmu_counter_is_enabled(struct kvm_vcpu *vcpu, u64 select_idx)
>>> @@ -420,7 +415,7 @@ static void kvm_pmu_create_perf_event(struct kvm_vcpu *vcpu, u64 select_idx)
>>>   
>>>   	counter = kvm_pmu_get_counter_value(vcpu, select_idx);
>>>   	/* The initial sample period (overflow count) of an event. */
>>> -	attr.sample_period = (-counter) & pmc->bitmask;
>>> +	attr.sample_period = (-counter) & GENMASK(31, 0);
>>
>> Isn't this the one case where the bitmask actually matters? If we're
>> dealing with the cycle counter, it shouldn't be truncated, right?
> 
> Ah yes, that should be conditional on idx as well.

The mask for Cycle counter also depends on the PMCR.LC field set by the
guest, isn't it ? So unless we correlate that with the idx, we could be
passing in wrong results ?

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

  reply	other threads:[~2019-06-10 12:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 15:30 [PATCH v8 0/6] KVM: arm/arm64: add support for chained counters Andrew Murray
2019-05-22 15:30 ` [PATCH v8 1/6] KVM: arm/arm64: rename kvm_pmu_{enable/disable}_counter functions Andrew Murray
2019-05-22 15:30 ` [PATCH v8 2/6] KVM: arm/arm64: extract duplicated code to own function Andrew Murray
2019-05-22 15:30 ` [PATCH v8 3/6] KVM: arm/arm64: re-create event when setting counter value Andrew Murray
2019-05-22 15:30 ` [PATCH v8 4/6] arm64: perf: extract chain helper into header Andrew Murray
2019-06-10 11:39   ` Will Deacon
2019-05-22 15:30 ` [PATCH v8 5/6] KVM: arm/arm64: remove pmc->bitmask Andrew Murray
2019-05-22 16:07   ` Marc Zyngier
2019-05-22 16:26     ` Andrew Murray
2019-06-10 12:54       ` Suzuki K Poulose [this message]
2019-06-12 14:30         ` Andrew Murray
2019-05-22 15:30 ` [PATCH v8 6/6] KVM: arm/arm64: support chained PMU counters Andrew Murray
2019-06-10 10:21   ` Julien Thierry
2019-06-10 16:05   ` Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=036304c6-d5a8-5b36-48e1-1e919c55fc4c@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=andrew.murray@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).