linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Murray <andrew.murray@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Julien Thierry <julien.thierry@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Christoffer Dall <christoffer.dall@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v8 5/5] arm64: KVM: Enable support for :G/:H perf event modifiers
Date: Wed, 12 Dec 2018 14:46:06 +0000	[thread overview]
Message-ID: <20181212144606.GB48249@e119886-lin.cambridge.arm.com> (raw)
In-Reply-To: <9aaf29ba-b320-fb5e-cbc8-3e6067e3ef26@arm.com>

On Wed, Dec 12, 2018 at 10:53:35AM +0000, Suzuki K Poulose wrote:
> 
> 
> On 12/12/2018 10:29, Andrew Murray wrote:
> > Enable/disable event counters as appropriate when entering and exiting
> > the guest to enable support for guest or host only event counting.
> > 
> > For both VHE and non-VHE we switch the counters between host/guest at
> > EL2. EL2 is filtered out by the PMU when we are using the :G modifier.
> > 
> > The PMU may be on when we change which counters are enabled however
> > we avoid adding an isb as we instead rely on existing context
> > synchronisation events: the isb in kvm_arm_vhe_guest_exit for VHE and
> > the eret from the hvc in kvm_call_hyp.
> > 
> > Signed-off-by: Andrew Murray <andrew.murray@arm.com>
> > ---
> >   arch/arm64/kvm/hyp/switch.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
> >   1 file changed, 52 insertions(+)
> > 
> > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
> > index d496ef5..9732ef7 100644
> > --- a/arch/arm64/kvm/hyp/switch.c
> > +++ b/arch/arm64/kvm/hyp/switch.c
> > @@ -373,6 +373,46 @@ static bool __hyp_text __hyp_switch_fpsimd(struct kvm_vcpu *vcpu)
> >   	return true;
> >   }
> > +static bool __hyp_text __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt)
> > +{
> > +	struct kvm_host_data *host;
> > +	struct kvm_pmu_events *pmu;
> > +	u32 clr, set;
> > +
> > +	host = container_of(host_ctxt, struct kvm_host_data, host_ctxt);
> > +	pmu = &host->pmu_events;
> > +
> > +	clr = pmu->events_host & ~pmu->events_guest;
> > +	set = pmu->events_guest & ~pmu->events_host;
> 
> It may make sense to add in a comment explaining why we only set:
> 
> 	events_guest & ~events_host
> 

Yes I'll add a comment, especially as I've just spend 5 minutes trying to
remember why I did this.

Instead of assigning 'pmu->events_guest & ~pmu->events_host' to 'set' we
could have just assigned 'pmu->events_guest'. However consider the scenario
where an event is enabled for both host and guest - this would have resulted
in us always writing the (already set) bit to the system register. Therefore
with my approach we can potentially avoid any system register writes on a 
hypervisor switch when the only events enabled are those for both host and
guest.

Thanks,

Andrew Murray

> Either way:
> 
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2018-12-12 14:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 10:29 [PATCH v8 0/5] arm64: Support perf event modifiers :G and :H Andrew Murray
2018-12-12 10:29 ` [PATCH v8 1/5] arm64: arm_pmu: remove unnecessary isb instruction Andrew Murray
2018-12-12 10:29 ` [PATCH v8 2/5] arm64: KVM: encapsulate kvm_cpu_context in kvm_host_data Andrew Murray
2018-12-12 10:37   ` Suzuki K Poulose
2018-12-12 12:31     ` Andrew Murray
2018-12-18 11:40   ` Christoffer Dall
2018-12-12 10:29 ` [PATCH v8 3/5] arm64: KVM: add accessors to track guest/host only counters Andrew Murray
2018-12-12 10:56   ` Suzuki K Poulose
2018-12-12 10:29 ` [PATCH v8 4/5] arm64: arm_pmu: Add support for exclude_host/exclude_guest attributes Andrew Murray
2018-12-12 10:42   ` Suzuki K Poulose
2018-12-12 10:47     ` Julien Thierry
2018-12-12 10:51       ` Suzuki K Poulose
2018-12-12 10:55   ` Suzuki K Poulose
2018-12-12 14:38     ` Andrew Murray
2018-12-18 12:02   ` Christoffer Dall
2018-12-18 13:25     ` Andrew Murray
2018-12-18 14:38       ` Christoffer Dall
2018-12-18 16:27         ` Andrew Murray
2018-12-18 18:51           ` Christoffer Dall
2018-12-18 19:19             ` Andrew Jones
2019-01-04 15:32     ` Will Deacon
2019-01-08 10:18       ` Christoffer Dall
2019-01-08 11:25         ` Andrew Murray
2019-01-08 11:50           ` Marc Zyngier
2019-01-08 12:03             ` Christoffer Dall
2019-01-08 12:12               ` Marc Zyngier
2019-01-08 12:20                 ` Christoffer Dall
2019-01-08 12:14           ` Christoffer Dall
2019-01-08 12:39             ` Andrew Murray
2018-12-12 10:29 ` [PATCH v8 5/5] arm64: KVM: Enable support for :G/:H perf event modifiers Andrew Murray
2018-12-12 10:53   ` Suzuki K Poulose
2018-12-12 14:46     ` Andrew Murray [this message]

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=20181212144606.GB48249@e119886-lin.cambridge.arm.com \
    --to=andrew.murray@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=julien.thierry@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will.deacon@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).