From: Raghavendra Rao Ananta <rananta@google.com>
To: Oliver Upton <oupton@google.com>,
Reiji Watanabe <reijiw@google.com>, Marc Zyngier <maz@kernel.org>,
Ricardo Koller <ricarkol@google.com>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Jing Zhang <jingzhangos@google.com>,
Colton Lewis <coltonlewis@google.com>,
Raghavendra Rao Anata <rananta@google.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [REPOST PATCH 14/16] selftests: KVM: aarch64: Add PMU test to chain all the counters
Date: Wed, 15 Feb 2023 01:07:15 +0000 [thread overview]
Message-ID: <20230215010717.3612794-15-rananta@google.com> (raw)
In-Reply-To: <20230215010717.3612794-1-rananta@google.com>
Extend the vCPU migration test to occupy all the vPMU counters,
by configuring chained events on alternate counter-ids and chaining
them with its corresponding predecessor counter, and verify against
the extended behavior.
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
.../testing/selftests/kvm/aarch64/vpmu_test.c | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/tools/testing/selftests/kvm/aarch64/vpmu_test.c b/tools/testing/selftests/kvm/aarch64/vpmu_test.c
index de725f4339ad5..fd00acb9391c8 100644
--- a/tools/testing/selftests/kvm/aarch64/vpmu_test.c
+++ b/tools/testing/selftests/kvm/aarch64/vpmu_test.c
@@ -710,6 +710,63 @@ static void test_chained_count(int pmc_idx)
pmu_irq_exit(chained_pmc_idx);
}
+static void test_chain_all_counters(void)
+{
+ int i;
+ uint64_t cnt, pmcr_n = get_pmcr_n();
+ struct pmc_accessor *acc = &pmc_accessors[0];
+
+ /*
+ * Test the occupancy of all the event counters, by chaining the
+ * alternate counters. The test assumes that the host hasn't
+ * occupied any counters. Hence, if the test fails, it could be
+ * because all the counters weren't available to the guest or
+ * there's actually a bug in KVM.
+ */
+
+ /*
+ * Configure even numbered counters to count cpu-cycles, and chain
+ * each of them with its odd numbered counter.
+ */
+ for (i = 0; i < pmcr_n; i++) {
+ if (i % 2) {
+ acc->write_typer(i, ARMV8_PMUV3_PERFCTR_CHAIN);
+ acc->write_cntr(i, 1);
+ } else {
+ pmu_irq_init(i);
+ acc->write_cntr(i, PRE_OVERFLOW_32);
+ acc->write_typer(i, ARMV8_PMUV3_PERFCTR_CPU_CYCLES);
+ }
+ enable_counter(i);
+ }
+
+ /* Introduce some cycles */
+ execute_precise_instrs(500, ARMV8_PMU_PMCR_E);
+
+ /*
+ * An overflow interrupt should've arrived for all the even numbered
+ * counters but none for the odd numbered ones. The odd numbered ones
+ * should've incremented exactly by 1.
+ */
+ for (i = 0; i < pmcr_n; i++) {
+ if (i % 2) {
+ GUEST_ASSERT_1(!pmu_irq_received(i), i);
+
+ cnt = acc->read_cntr(i);
+ GUEST_ASSERT_2(cnt == 2, i, cnt);
+ } else {
+ GUEST_ASSERT_1(pmu_irq_received(i), i);
+ }
+ }
+
+ /* Cleanup the states */
+ for (i = 0; i < pmcr_n; i++) {
+ if (i % 2 == 0)
+ pmu_irq_exit(i);
+ disable_counter(i);
+ }
+}
+
static void test_event_count(uint64_t event, int pmc_idx, bool expect_count)
{
switch (event) {
@@ -739,6 +796,9 @@ static void test_basic_pmu_functionality(void)
/* Test chained events */
test_chained_count(0);
+
+ /* Test running chained events on all the implemented counters */
+ test_chain_all_counters();
}
/*
--
2.39.1.581.gbfd45094c4-goog
next prev parent reply other threads:[~2023-02-15 1:08 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 1:07 [REPOST PATCH 00/16] Add support for vPMU selftests Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 01/16] tools: arm64: Import perf_event.h Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 02/16] KVM: selftests: aarch64: Introduce vpmu_counter_access test Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 03/16] KVM: selftests: aarch64: vPMU register test for implemented counters Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 04/16] KVM: selftests: aarch64: vPMU register test for unimplemented counters Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 05/16] selftests: KVM: aarch64: Refactor the vPMU counter access tests Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 06/16] tools: arm64: perf_event: Define Cycle counter enable/overflow bits Raghavendra Rao Ananta
2023-03-03 0:46 ` Reiji Watanabe
2023-03-09 22:14 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 07/16] selftests: KVM: aarch64: Add PMU cycle counter helpers Raghavendra Rao Ananta
2023-03-03 3:06 ` Reiji Watanabe
2023-03-09 22:19 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 08/16] selftests: KVM: aarch64: Consider PMU event filters for VM creation Raghavendra Rao Ananta
2023-03-03 4:30 ` Reiji Watanabe
2023-03-09 22:45 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 09/16] selftests: KVM: aarch64: Add KVM PMU event filter test Raghavendra Rao Ananta
2023-03-04 20:28 ` Reiji Watanabe
2023-03-09 23:17 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 10/16] selftests: KVM: aarch64: Add KVM EVTYPE filter PMU test Raghavendra Rao Ananta
2023-03-07 1:19 ` Reiji Watanabe
2023-03-07 16:09 ` Sean Christopherson
2023-03-10 21:57 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 11/16] selftests: KVM: aarch64: Add vCPU migration test for PMU Raghavendra Rao Ananta
2023-03-07 3:43 ` Reiji Watanabe
2023-03-10 2:28 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 12/16] selftests: KVM: aarch64: Test PMU overflow/IRQ functionality Raghavendra Rao Ananta
2023-03-07 6:09 ` Reiji Watanabe
2023-03-08 1:19 ` Reiji Watanabe
2023-03-10 23:58 ` Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 13/16] selftests: KVM: aarch64: Test chained events for PMU Raghavendra Rao Ananta
2023-03-08 3:15 ` Reiji Watanabe
2023-02-15 1:07 ` Raghavendra Rao Ananta [this message]
2023-03-08 3:40 ` [REPOST PATCH 14/16] selftests: KVM: aarch64: Add PMU test to chain all the counters Reiji Watanabe
2023-02-15 1:07 ` [REPOST PATCH 15/16] selftests: KVM: aarch64: Add multi-vCPU support for vPMU VM creation Raghavendra Rao Ananta
2023-02-15 1:07 ` [REPOST PATCH 16/16] selftests: KVM: aarch64: Extend the vCPU migration test to multi-vCPUs Raghavendra Rao Ananta
2023-03-08 4:44 ` 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=20230215010717.3612794-15-rananta@google.com \
--to=rananta@google.com \
--cc=coltonlewis@google.com \
--cc=james.morse@arm.com \
--cc=jingzhangos@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=reijiw@google.com \
--cc=ricarkol@google.com \
--cc=suzuki.poulose@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