From: Andrew Jones <ajones@ventanamicro.com>
To: Atish Patra <atishp@rivosinc.com>
Cc: Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: riscv: selftests: Change command line option
Date: Thu, 27 Feb 2025 09:08:32 +0100 [thread overview]
Message-ID: <20250227-eb9e3d8de1de2ff609ac8f64@orel> (raw)
In-Reply-To: <20250226-kvm_pmu_improve-v1-3-74c058c2bf6d@rivosinc.com>
On Wed, Feb 26, 2025 at 12:25:05PM -0800, Atish Patra wrote:
> The PMU test commandline option takes an argument to disable a
> certain test. The initial assumption behind this was a common use case
> is just to run all the test most of the time. However, running a single
> test seems more useful instead. Especially, the overflow test has been
> helpful to validate PMU virtualizaiton interrupt changes.
>
> Switching the command line option to run a single test instead
> of disabling a single test also allows to provide additional
> test specific arguments to the test. The default without any options
> remains unchanged which continues to run all the tests.
>
> Signed-off-by: Atish Patra <atishp@rivosinc.com>
> ---
> tools/testing/selftests/kvm/riscv/sbi_pmu_test.c | 40 +++++++++++++++---------
> 1 file changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c
> index 284bc80193bd..533b76d0de82 100644
> --- a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c
> +++ b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c
> @@ -39,7 +39,11 @@ static bool illegal_handler_invoked;
> #define SBI_PMU_TEST_SNAPSHOT BIT(2)
> #define SBI_PMU_TEST_OVERFLOW BIT(3)
>
> -static int disabled_tests;
> +struct test_args {
> + int disabled_tests;
> +};
> +
> +static struct test_args targs;
>
> unsigned long pmu_csr_read_num(int csr_num)
> {
> @@ -604,7 +608,11 @@ static void test_vm_events_overflow(void *guest_code)
> vcpu_init_vector_tables(vcpu);
> /* Initialize guest timer frequency. */
> timer_freq = vcpu_get_reg(vcpu, RISCV_TIMER_REG(frequency));
> +
> + /* Export the shared variables to the guest */
> sync_global_to_guest(vm, timer_freq);
> + sync_global_to_guest(vm, vcpu_shared_irq_count);
> + sync_global_to_guest(vm, targs);
>
> run_vcpu(vcpu);
>
> @@ -613,28 +621,30 @@ static void test_vm_events_overflow(void *guest_code)
>
> static void test_print_help(char *name)
> {
> - pr_info("Usage: %s [-h] [-d <test name>]\n", name);
> - pr_info("\t-d: Test to disable. Available tests are 'basic', 'events', 'snapshot', 'overflow'\n");
> + pr_info("Usage: %s [-h] [-t <test name>]\n", name);
> + pr_info("\t-t: Test to run (default all). Available tests are 'basic', 'events', 'snapshot', 'overflow'\n");
It's probably fine to drop '-d', since we don't make any claims about
support, but doing so does risk breaking some CI somewhere. If that
potential breakage is a concern, then we could keep '-d', since nothing
stops us from having both.
> pr_info("\t-h: print this help screen\n");
> }
>
> static bool parse_args(int argc, char *argv[])
> {
> int opt;
> -
> - while ((opt = getopt(argc, argv, "hd:")) != -1) {
> + int temp_disabled_tests = SBI_PMU_TEST_BASIC | SBI_PMU_TEST_EVENTS | SBI_PMU_TEST_SNAPSHOT |
> + SBI_PMU_TEST_OVERFLOW;
> + while ((opt = getopt(argc, argv, "h:t:n:")) != -1) {
'-h' doesn't need an argument and '-n' should be introduced with the next
patch.
> switch (opt) {
> - case 'd':
> + case 't':
> if (!strncmp("basic", optarg, 5))
> - disabled_tests |= SBI_PMU_TEST_BASIC;
> + temp_disabled_tests &= ~SBI_PMU_TEST_BASIC;
> else if (!strncmp("events", optarg, 6))
> - disabled_tests |= SBI_PMU_TEST_EVENTS;
> + temp_disabled_tests &= ~SBI_PMU_TEST_EVENTS;
> else if (!strncmp("snapshot", optarg, 8))
> - disabled_tests |= SBI_PMU_TEST_SNAPSHOT;
> + temp_disabled_tests &= ~SBI_PMU_TEST_SNAPSHOT;
> else if (!strncmp("overflow", optarg, 8))
> - disabled_tests |= SBI_PMU_TEST_OVERFLOW;
> + temp_disabled_tests &= ~SBI_PMU_TEST_OVERFLOW;
> else
> goto done;
> + targs.disabled_tests = temp_disabled_tests;
> break;
> case 'h':
> default:
> @@ -650,25 +660,27 @@ static bool parse_args(int argc, char *argv[])
>
> int main(int argc, char *argv[])
> {
> + targs.disabled_tests = 0;
> +
> if (!parse_args(argc, argv))
> exit(KSFT_SKIP);
>
> - if (!(disabled_tests & SBI_PMU_TEST_BASIC)) {
> + if (!(targs.disabled_tests & SBI_PMU_TEST_BASIC)) {
> test_vm_basic_test(test_pmu_basic_sanity);
> pr_info("SBI PMU basic test : PASS\n");
> }
>
> - if (!(disabled_tests & SBI_PMU_TEST_EVENTS)) {
> + if (!(targs.disabled_tests & SBI_PMU_TEST_EVENTS)) {
> test_vm_events_test(test_pmu_events);
> pr_info("SBI PMU event verification test : PASS\n");
> }
>
> - if (!(disabled_tests & SBI_PMU_TEST_SNAPSHOT)) {
> + if (!(targs.disabled_tests & SBI_PMU_TEST_SNAPSHOT)) {
> test_vm_events_snapshot_test(test_pmu_events_snaphost);
> pr_info("SBI PMU event verification with snapshot test : PASS\n");
> }
>
> - if (!(disabled_tests & SBI_PMU_TEST_OVERFLOW)) {
> + if (!(targs.disabled_tests & SBI_PMU_TEST_OVERFLOW)) {
> test_vm_events_overflow(test_pmu_events_overflow);
> pr_info("SBI PMU event verification with overflow test : PASS\n");
> }
>
> --
> 2.43.0
>
Otherwise,
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
next prev parent reply other threads:[~2025-02-27 8:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 20:25 [PATCH 0/4] RISC-V KVM PMU fix and selftest improvement Atish Patra
2025-02-26 20:25 ` [PATCH 1/4] RISC-V: KVM: Disable the kernel perf counter during configure Atish Patra
2025-02-27 8:49 ` Andrew Jones
2025-02-26 20:25 ` [PATCH 2/4] KVM: riscv: selftests: Do not start the counter in the overflow handler Atish Patra
2025-02-27 8:44 ` Andrew Jones
2025-02-26 20:25 ` [PATCH 3/4] KVM: riscv: selftests: Change command line option Atish Patra
2025-02-27 8:08 ` Andrew Jones [this message]
2025-03-03 20:53 ` Atish Kumar Patra
2025-02-26 20:25 ` [PATCH 4/4] KVM: riscv: selftests: Allow number of interrupts to be configurable Atish Patra
2025-02-27 8:16 ` Andrew Jones
2025-03-03 21:27 ` Atish Kumar Patra
2025-03-04 8:58 ` Andrew Jones
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=20250227-eb9e3d8de1de2ff609ac8f64@orel \
--to=ajones@ventanamicro.com \
--cc=anup@brainfault.org \
--cc=atishp@atishpatra.org \
--cc=atishp@rivosinc.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/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