All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Reiji Watanabe <reijiw@google.com>
Cc: kvm@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	kvmarm@lists.linux.dev, Paolo Bonzini <pbonzini@redhat.com>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU
Date: Tue, 3 Jan 2023 12:40:34 +0000	[thread overview]
Message-ID: <20230103124034.000027aa@Huawei.com> (raw)
In-Reply-To: <20221230035928.3423990-1-reijiw@google.com>

On Thu, 29 Dec 2022 19:59:21 -0800
Reiji Watanabe <reijiw@google.com> wrote:

> The goal of this series is to allow userspace to limit the number
> of PMU event counters on the vCPU.

Hi Rieji,

Why do you want to do this?

I can conjecture a bunch of possible reasons, but they may not
match up with your use case. It would be useful to have that information
in the cover letter.

Jonathan

> 
> The number of PMU event counters is indicated in PMCR_EL0.N.
> For a vCPU with PMUv3 configured, its value will be the same as
> the host value by default. Userspace can set PMCR_EL0.N for the
> vCPU to a lower value than the host value, using KVM_SET_ONE_REG.
> However, it is practically unsupported, as KVM resets PMCR_EL0.N
> to the host value on vCPU reset and some KVM code uses the host
> value to identify (un)implemented event counters on the vCPU.
> 
> This series will ensure that the PMCR_EL0.N value is preserved
> on vCPU reset and that KVM doesn't use the host value
> to identify (un)implemented event counters on the vCPU.
> This allows userspace to limit the number of the PMU event
> counters on the vCPU.
> 
> Patch 1 fixes reset_pmu_reg() to ensure that (RAZ) bits of
> {PMCNTEN,PMOVS}{SET,CLR}_EL1 corresponding to unimplemented event
> counters on the vCPU are reset to zero even when PMCR_EL0.N for
> the vCPU is different from the host.
> 
> Patch 2 is a minor refactoring to use the default PMU register reset
> function (reset_pmu_reg()) for PMUSERENR_EL0 and PMCCFILTR_EL0.
> (With the Patch 1 change, reset_pmu_reg() can now be used for
> those registers)
> 
> Patch 3 fixes reset_pmcr() to preserve PMCR_EL0.N for the vCPU on
> vCPU reset.
> 
> Patch 4-7 adds a selftest to verify reading and writing PMU registers
> for implemented or unimplemented PMU event counters on the vCPU.
> 
> The series is based on kvmarm/fixes at the following commit:
>   commit aff234839f8b ("KVM: arm64: PMU: Fix PMCR_EL0 reset value")
> 
> Reiji Watanabe (7):
>   KVM: arm64: PMU: Have reset_pmu_reg() to clear a register
>   KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and
>     PMCCFILTR_EL0
>   KVM: arm64: PMU: Preserve vCPU's PMCR_EL0.N value on vCPU reset
>   tools: arm64: Import perf_event.h
>   KVM: selftests: aarch64: Introduce vpmu_counter_access test
>   KVM: selftests: aarch64: vPMU register test for implemented counters
>   KVM: selftests: aarch64: vPMU register test for unimplemented counters
> 
>  arch/arm64/kvm/pmu-emul.c                     |   6 +
>  arch/arm64/kvm/sys_regs.c                     |  18 +-
>  tools/arch/arm64/include/asm/perf_event.h     | 258 ++++++++
>  tools/testing/selftests/kvm/.gitignore        |   1 +
>  tools/testing/selftests/kvm/Makefile          |   1 +
>  .../kvm/aarch64/vpmu_counter_access.c         | 613 ++++++++++++++++++
>  .../selftests/kvm/include/aarch64/processor.h |   1 +
>  7 files changed, 886 insertions(+), 12 deletions(-)
>  create mode 100644 tools/arch/arm64/include/asm/perf_event.h
>  create mode 100644 tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c
> 
> 
> base-commit: aff234839f8b80ac101e6c2f14d0e44b236efa48

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

WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Reiji Watanabe <reijiw@google.com>
Cc: Marc Zyngier <maz@kernel.org>, <kvmarm@lists.cs.columbia.edu>,
	<kvmarm@lists.linux.dev>, <kvm@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Ricardo Koller" <ricarkol@google.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	"Jing Zhang" <jingzhangos@google.com>,
	Raghavendra Rao Anata <rananta@google.com>
Subject: Re: [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU
Date: Tue, 3 Jan 2023 12:40:34 +0000	[thread overview]
Message-ID: <20230103124034.000027aa@Huawei.com> (raw)
Message-ID: <20230103124034.Kq-t2pRdc51kYqqEpLdxTqIQVhuVUeWzkub7bGcWzpg@z> (raw)
In-Reply-To: <20221230035928.3423990-1-reijiw@google.com>

On Thu, 29 Dec 2022 19:59:21 -0800
Reiji Watanabe <reijiw@google.com> wrote:

> The goal of this series is to allow userspace to limit the number
> of PMU event counters on the vCPU.

Hi Rieji,

Why do you want to do this?

I can conjecture a bunch of possible reasons, but they may not
match up with your use case. It would be useful to have that information
in the cover letter.

Jonathan

> 
> The number of PMU event counters is indicated in PMCR_EL0.N.
> For a vCPU with PMUv3 configured, its value will be the same as
> the host value by default. Userspace can set PMCR_EL0.N for the
> vCPU to a lower value than the host value, using KVM_SET_ONE_REG.
> However, it is practically unsupported, as KVM resets PMCR_EL0.N
> to the host value on vCPU reset and some KVM code uses the host
> value to identify (un)implemented event counters on the vCPU.
> 
> This series will ensure that the PMCR_EL0.N value is preserved
> on vCPU reset and that KVM doesn't use the host value
> to identify (un)implemented event counters on the vCPU.
> This allows userspace to limit the number of the PMU event
> counters on the vCPU.
> 
> Patch 1 fixes reset_pmu_reg() to ensure that (RAZ) bits of
> {PMCNTEN,PMOVS}{SET,CLR}_EL1 corresponding to unimplemented event
> counters on the vCPU are reset to zero even when PMCR_EL0.N for
> the vCPU is different from the host.
> 
> Patch 2 is a minor refactoring to use the default PMU register reset
> function (reset_pmu_reg()) for PMUSERENR_EL0 and PMCCFILTR_EL0.
> (With the Patch 1 change, reset_pmu_reg() can now be used for
> those registers)
> 
> Patch 3 fixes reset_pmcr() to preserve PMCR_EL0.N for the vCPU on
> vCPU reset.
> 
> Patch 4-7 adds a selftest to verify reading and writing PMU registers
> for implemented or unimplemented PMU event counters on the vCPU.
> 
> The series is based on kvmarm/fixes at the following commit:
>   commit aff234839f8b ("KVM: arm64: PMU: Fix PMCR_EL0 reset value")
> 
> Reiji Watanabe (7):
>   KVM: arm64: PMU: Have reset_pmu_reg() to clear a register
>   KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and
>     PMCCFILTR_EL0
>   KVM: arm64: PMU: Preserve vCPU's PMCR_EL0.N value on vCPU reset
>   tools: arm64: Import perf_event.h
>   KVM: selftests: aarch64: Introduce vpmu_counter_access test
>   KVM: selftests: aarch64: vPMU register test for implemented counters
>   KVM: selftests: aarch64: vPMU register test for unimplemented counters
> 
>  arch/arm64/kvm/pmu-emul.c                     |   6 +
>  arch/arm64/kvm/sys_regs.c                     |  18 +-
>  tools/arch/arm64/include/asm/perf_event.h     | 258 ++++++++
>  tools/testing/selftests/kvm/.gitignore        |   1 +
>  tools/testing/selftests/kvm/Makefile          |   1 +
>  .../kvm/aarch64/vpmu_counter_access.c         | 613 ++++++++++++++++++
>  .../selftests/kvm/include/aarch64/processor.h |   1 +
>  7 files changed, 886 insertions(+), 12 deletions(-)
>  create mode 100644 tools/arch/arm64/include/asm/perf_event.h
>  create mode 100644 tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c
> 
> 
> base-commit: aff234839f8b80ac101e6c2f14d0e44b236efa48


WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Reiji Watanabe <reijiw@google.com>
Cc: Marc Zyngier <maz@kernel.org>, <kvmarm@lists.cs.columbia.edu>,
	<kvmarm@lists.linux.dev>, <kvm@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Ricardo Koller" <ricarkol@google.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	"Jing Zhang" <jingzhangos@google.com>,
	Raghavendra Rao Anata <rananta@google.com>
Subject: Re: [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU
Date: Tue, 3 Jan 2023 12:40:34 +0000	[thread overview]
Message-ID: <20230103124034.000027aa@Huawei.com> (raw)
In-Reply-To: <20221230035928.3423990-1-reijiw@google.com>

On Thu, 29 Dec 2022 19:59:21 -0800
Reiji Watanabe <reijiw@google.com> wrote:

> The goal of this series is to allow userspace to limit the number
> of PMU event counters on the vCPU.

Hi Rieji,

Why do you want to do this?

I can conjecture a bunch of possible reasons, but they may not
match up with your use case. It would be useful to have that information
in the cover letter.

Jonathan

> 
> The number of PMU event counters is indicated in PMCR_EL0.N.
> For a vCPU with PMUv3 configured, its value will be the same as
> the host value by default. Userspace can set PMCR_EL0.N for the
> vCPU to a lower value than the host value, using KVM_SET_ONE_REG.
> However, it is practically unsupported, as KVM resets PMCR_EL0.N
> to the host value on vCPU reset and some KVM code uses the host
> value to identify (un)implemented event counters on the vCPU.
> 
> This series will ensure that the PMCR_EL0.N value is preserved
> on vCPU reset and that KVM doesn't use the host value
> to identify (un)implemented event counters on the vCPU.
> This allows userspace to limit the number of the PMU event
> counters on the vCPU.
> 
> Patch 1 fixes reset_pmu_reg() to ensure that (RAZ) bits of
> {PMCNTEN,PMOVS}{SET,CLR}_EL1 corresponding to unimplemented event
> counters on the vCPU are reset to zero even when PMCR_EL0.N for
> the vCPU is different from the host.
> 
> Patch 2 is a minor refactoring to use the default PMU register reset
> function (reset_pmu_reg()) for PMUSERENR_EL0 and PMCCFILTR_EL0.
> (With the Patch 1 change, reset_pmu_reg() can now be used for
> those registers)
> 
> Patch 3 fixes reset_pmcr() to preserve PMCR_EL0.N for the vCPU on
> vCPU reset.
> 
> Patch 4-7 adds a selftest to verify reading and writing PMU registers
> for implemented or unimplemented PMU event counters on the vCPU.
> 
> The series is based on kvmarm/fixes at the following commit:
>   commit aff234839f8b ("KVM: arm64: PMU: Fix PMCR_EL0 reset value")
> 
> Reiji Watanabe (7):
>   KVM: arm64: PMU: Have reset_pmu_reg() to clear a register
>   KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and
>     PMCCFILTR_EL0
>   KVM: arm64: PMU: Preserve vCPU's PMCR_EL0.N value on vCPU reset
>   tools: arm64: Import perf_event.h
>   KVM: selftests: aarch64: Introduce vpmu_counter_access test
>   KVM: selftests: aarch64: vPMU register test for implemented counters
>   KVM: selftests: aarch64: vPMU register test for unimplemented counters
> 
>  arch/arm64/kvm/pmu-emul.c                     |   6 +
>  arch/arm64/kvm/sys_regs.c                     |  18 +-
>  tools/arch/arm64/include/asm/perf_event.h     | 258 ++++++++
>  tools/testing/selftests/kvm/.gitignore        |   1 +
>  tools/testing/selftests/kvm/Makefile          |   1 +
>  .../kvm/aarch64/vpmu_counter_access.c         | 613 ++++++++++++++++++
>  .../selftests/kvm/include/aarch64/processor.h |   1 +
>  7 files changed, 886 insertions(+), 12 deletions(-)
>  create mode 100644 tools/arch/arm64/include/asm/perf_event.h
>  create mode 100644 tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c
> 
> 
> base-commit: aff234839f8b80ac101e6c2f14d0e44b236efa48


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

  parent reply	other threads:[~2023-01-03 12:40 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30  3:59 [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU Reiji Watanabe
2022-12-30  3:59 ` Reiji Watanabe
2022-12-30  3:59 ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 1/7] KVM: arm64: PMU: Have reset_pmu_reg() to clear a register Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2023-01-08 19:07   ` Oliver Upton
2023-01-08 19:07     ` Oliver Upton
2023-01-10  5:50     ` Reiji Watanabe
2023-01-10  5:50       ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 2/7] KVM: arm64: PMU: Use reset_pmu_reg() for PMUSERENR_EL0 and PMCCFILTR_EL0 Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2023-01-08 19:13   ` Oliver Upton
2023-01-08 19:13     ` Oliver Upton
2023-01-10  1:17     ` Reiji Watanabe
2023-01-10  1:17       ` Reiji Watanabe
2023-01-10  1:46       ` Oliver Upton
2023-01-10  1:46         ` Oliver Upton
2022-12-30  3:59 ` [PATCH 3/7] KVM: arm64: PMU: Preserve vCPU's PMCR_EL0.N value on vCPU reset Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 4/7] tools: arm64: Import perf_event.h Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 5/7] KVM: selftests: aarch64: Introduce vpmu_counter_access test Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 6/7] KVM: selftests: aarch64: vPMU register test for implemented counters Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59 ` [PATCH 7/7] KVM: selftests: aarch64: vPMU register test for unimplemented counters Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2022-12-30  3:59   ` Reiji Watanabe
2023-01-03 12:40 ` Jonathan Cameron [this message]
2023-01-03 12:40   ` [PATCH 0/7] KVM: arm64: PMU: Allow userspace to limit the number of PMCs on vCPU Jonathan Cameron
2023-01-03 12:40   ` Jonathan Cameron
2023-01-03 12:47   ` Marc Zyngier
2023-01-03 12:47     ` Marc Zyngier
2023-01-03 12:47     ` Marc Zyngier
2023-01-05  2:59     ` Reiji Watanabe
2023-01-05  2:59       ` Reiji Watanabe
2023-01-05  2:59       ` Reiji Watanabe
2023-01-10  2:01 ` Oliver Upton
2023-01-10  2:01   ` Oliver Upton
2023-01-11  0:55   ` Reiji Watanabe
2023-01-11  0:55     ` Reiji Watanabe

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=20230103124034.000027aa@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=reijiw@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.