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: [PATCH 11/13] selftests: KVM: aarch64: Add PMU test to chain all the counters
Date: Mon, 13 Feb 2023 18:02:32 +0000 [thread overview]
Message-ID: <20230213180234.2885032-12-rananta@google.com> (raw)
In-Reply-To: <20230213180234.2885032-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
WARNING: multiple messages have this Message-ID (diff)
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: [PATCH 11/13] selftests: KVM: aarch64: Add PMU test to chain all the counters
Date: Mon, 13 Feb 2023 18:02:32 +0000 [thread overview]
Message-ID: <20230213180234.2885032-12-rananta@google.com> (raw)
In-Reply-To: <20230213180234.2885032-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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-13 18:02 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 18:02 [PATCH 00/13] Extend the vPMU selftest Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 01/13] selftests: KVM: aarch64: Rename vpmu_counter_access.c to vpmu_test.c Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 02/13] selftests: KVM: aarch64: Refactor the vPMU counter access tests Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 03/13] tools: arm64: perf_event: Define Cycle counter enable/overflow bits Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 04/13] selftests: KVM: aarch64: Add PMU cycle counter helpers Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 05/13] selftests: KVM: aarch64: Consider PMU event filters for VM creation Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 06/13] selftests: KVM: aarch64: Add KVM PMU event filter test Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 07/13] selftests: KVM: aarch64: Add KVM EVTYPE filter PMU test Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 08/13] selftests: KVM: aarch64: Add vCPU migration test for PMU Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 09/13] selftests: KVM: aarch64: Test PMU overflow/IRQ functionality Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 10/13] selftests: KVM: aarch64: Test chained events for PMU Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta [this message]
2023-02-13 18:02 ` [PATCH 11/13] selftests: KVM: aarch64: Add PMU test to chain all the counters Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 12/13] selftests: KVM: aarch64: Add multi-vCPU support for vPMU VM creation Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 18:02 ` [PATCH 13/13] selftests: KVM: aarch64: Extend the vCPU migration test to multi-vCPUs Raghavendra Rao Ananta
2023-02-13 18:02 ` Raghavendra Rao Ananta
2023-02-13 23:39 ` [PATCH 00/13] Extend the vPMU selftest Raghavendra Rao Ananta
2023-02-13 23:39 ` Raghavendra Rao Ananta
2023-02-14 8:19 ` Oliver Upton
2023-02-14 8:19 ` Oliver Upton
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=20230213180234.2885032-12-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 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.