Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1925366lqp; Tue, 16 Apr 2024 01:49:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9znDYB/1vpN/dl5hfps3H2b1gSVqTFyeRtqGKM7psG5A20huoVpPFd3O/kfcdkNHhtK6tOlt+pZpEyvm+1IktCXzVXpbim+03faPotA== X-Google-Smtp-Source: AGHT+IG9JN8W+z9ERHvhIvqTklZNn22eFhCQc/j/IQfKcuJc+aqtG6MJ87GvuioSRrKDv5MnirR2 X-Received: by 2002:a05:620a:1912:b0:78d:47fd:5c8c with SMTP id bj18-20020a05620a191200b0078d47fd5c8cmr15486279qkb.1.1713257399127; Tue, 16 Apr 2024 01:49:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713257399; cv=pass; d=google.com; s=arc-20160816; b=NV5EcODAQ0GTWVYvsKSQ3SaynJfQK4D/5fPkmIsKkDPlYfHLycZcWqxQFE2JDAPvOv v3ZkSo8afUcKt9UD0MOOJwjg+8UoyVZspJS119nRLaG/K7gMLytfrd6tw1qyG7UYiO5n Km2UUvZfjXYxoiPQbLg1SXvA2LCIqzIkWoYbhrXQAEDkqO0DfVEsxXrHA/HaXva9rDdM OYpjUzaCsDLlISyPKUdefhnrWYMqjn5dPoDxbhRFkHRlhPUXzR1eZwT+E5E8yvjFfa79 1rBRWnXiV0tYIJWe+F0IPsdu6AtGBqEOPS3L2MUHqCM+aADQaFWO+CNXR6v7o0CoqiTL iS+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=YB4OKZ5azyoBQVdDaeHRwpejD252N/Wm8xYNs68na58=; fh=Uk7RzoWEZMxvk778/bzmvccArGy7d1fiQUoCb0BXKMo=; b=ntI6TURR9npqFmuDpARNMJv21H2KbrWhQB7QkrHiXSPuT6hTb3C2WPcSB4LDeNfHZK EtrMyvNEiJCHT8aMH9DJElqd+KhZEsNspTcsfqTtxCa6A1D7vUvIdkWV9GlB9Ek7L3xP mRHwQsLOiRQ4xgLbGRw5q5eMfctAvcKIlRJqpt3ToRLIv6nqi4tyEePsjM3VWYav02RI SboIqiuL5rSnnphU40ObirO4H0kI+Vyl8boN7iJpL2KUwpxtzPqrfy8SQKIgsSwQmirI GSZZbZLMX2marA6y+Sq1GN+gMMbLvffost9UQ/Vgom6slB0lJtJY7B0QTfNFfR9YK46A a29g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PdOYWbRE; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-146515-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146515-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u7-20020a05620a120700b0078ee4546280si4453742qkj.467.2024.04.16.01.49.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 01:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146515-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=PdOYWbRE; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-146515-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146515-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C67A81C20EEB for ; Tue, 16 Apr 2024 08:49:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EA2B85291; Tue, 16 Apr 2024 08:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="PdOYWbRE" Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9C6C84DE4 for ; Tue, 16 Apr 2024 08:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713257349; cv=none; b=FVscwP6yxQ+ATFvU9xmBbjW2enidoNgHeoJeo2HRfbT8x+XmyTkXAmvVkGgHPZnlz0h7oH26DzE9fq1qmoiz/mR0fU7Mnu7Uhuf7mRc0dnsUMT8tGCud2kSi9STT8Oj7i+aYGxXrLWo2QV0vAL/iD9rAa30OYC0CidOYXRhkv7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713257349; c=relaxed/simple; bh=5Ugj44ELKaezQMYHW4xB3ZcmBsV3qnLcoNGHNm1mHxM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K3tcwSlXA0aGm+ve3RwN5dnpJRd+znRC7on20Uy4mu19R/VAtjD4fYz4645Rq3hMw71kqsryhpVyG8XmvXXx9h8KO0NzSOPUqCl8h+crc5r9BWhNi2hrY9Lu9XaKshmpP352zWAWnIgUd6oqTpPfyqWRACkhp7lA4a+9Nne8OEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=PdOYWbRE; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2a54fb929c8so2664058a91.3 for ; Tue, 16 Apr 2024 01:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713257347; x=1713862147; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YB4OKZ5azyoBQVdDaeHRwpejD252N/Wm8xYNs68na58=; b=PdOYWbREAycb+IT5cv0/iFArt+jZqZKo8J7Vy8pwYMFdow2wq3pdH1uWBFOgw/+qKU Hh8lCRGtZrRtTdIHw44XdwaTc2ip/kDJ7DC+RxkuvvUavkpJ92gzUZXLmSBdbkCF95dy KVTjfW3sS8xeieHpQuVW9hHr9w+lffE62ofon0pUPPVOMHUNvRZvpHgxf8nJ7OrvOnKi 6pcPVpr4nunH9u4MjyG/U0v7eDZF+i3SDUKbaL70dNyA+q38Or6Wgq7wSIMSIIiLZZ6s ehpDuojEDSMQzoF+PqB5l97JLVQIXEzPlHr7nbZoWeQx5hI4DVEWun7EBG7TkwaZzVd3 wtiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713257347; x=1713862147; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YB4OKZ5azyoBQVdDaeHRwpejD252N/Wm8xYNs68na58=; b=mT2W9MaR5OB10kXi8pxzm2K3fdWO/aMGHPaBzdP+wMjkhaTqhJgcyKBMqhpchiwNOz CKRCdg06KYXzJnJ4E4P2lDkW+A78ent8qzzkaIgJvN0NqvD60ScU2UMw3YTG5CDoM6Jy OYrbOZDFa1W7elLHArAQ8OT9YqQCFPX2k8tOFI/uJ1AOYvilhVH7DAmxB7p4UluovDOu HTtkmbn/0753mK7K5xP4al/YoIXyF+rL2EfP0NFfmetLN2N6CP6fVzyXbHUIBusyOSmO aOqDEOxvkolv3vD+0bi16tKMbjYeUAqiTfTqcTGls8nwoCNH/6Q3dt8SpRWDpkzMFzAD cB3w== X-Gm-Message-State: AOJu0YwND7EB33wKj2x7YJB/8GGt2Nfyod1bv3p6YlLfd0xacb1SqGAG VGW60Kt7X4Te3ZPnYnNTmYo9HkBRx8Ud7tI4Tgp6uKBvItaoH8MYlBlGhxmv5yU= X-Received: by 2002:a17:90a:ae12:b0:2a0:5f10:990c with SMTP id t18-20020a17090aae1200b002a05f10990cmr11367042pjq.10.1713257347059; Tue, 16 Apr 2024 01:49:07 -0700 (PDT) Received: from [172.16.0.33] (c-67-188-2-18.hsd1.ca.comcast.net. [67.188.2.18]) by smtp.gmail.com with ESMTPSA id c9-20020a17090abf0900b002a610ef880bsm8721392pjs.6.2024.04.16.01.49.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Apr 2024 01:49:06 -0700 (PDT) Message-ID: Date: Tue, 16 Apr 2024 01:49:04 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 24/24] KVM: riscv: selftests: Add commandline option for SBI PMU test Content-Language: en-US To: Andrew Jones Cc: linux-kernel@vger.kernel.org, Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , Atish Patra , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, Will Deacon , x86@kernel.org References: <20240411000752.955910-1-atishp@rivosinc.com> <20240411000752.955910-25-atishp@rivosinc.com> <20240415-8b9ad5a7e968b1808e99e3da@orel> From: Atish Patra In-Reply-To: <20240415-8b9ad5a7e968b1808e99e3da@orel> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/15/24 06:43, Andrew Jones wrote: > On Wed, Apr 10, 2024 at 05:07:52PM -0700, Atish Patra wrote: >> SBI PMU test comprises of multiple tests and user may want to run >> only a subset depending on the platform. The most common case would >> be to run all to validate all the tests. However, some platform may >> not support all events or all ISA extensions. >> >> The commandline option allows user to disable particular test if they >> want to. >> >> Suggested-by: Andrew Jones >> Signed-off-by: Atish Patra >> --- >> .../selftests/kvm/riscv/sbi_pmu_test.c | 77 ++++++++++++++++--- >> 1 file changed, 68 insertions(+), 9 deletions(-) >> >> diff --git a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c >> index 0fd9b76ae838..57025b07a403 100644 >> --- a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c >> +++ b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c >> @@ -33,6 +33,16 @@ static unsigned long counter_mask_available; >> >> static bool illegal_handler_invoked; >> >> +enum sbi_pmu_test_id { >> + SBI_PMU_TEST_BASIC = 0, >> + SBI_PMU_TEST_EVENTS, >> + SBI_PMU_TEST_SNAPSHOT, >> + SBI_PMU_TEST_OVERFLOW, >> + SBI_PMU_TEST_MAX, >> +}; >> + >> +static int disabled_test_id = SBI_PMU_TEST_MAX; > > I think we should allow specifying '-d' multiple times in case a user > wants to disable more than one type of test. So we should set a bit > in this variable instead of assigning it. We could also flip it > around. If the user uses '-e' to enable test type then only type > will be run, but then we'd probably want to allow multiple '-e' > too so it doesn't gain anything. > Sure. Added multiple disable option. >> + >> unsigned long pmu_csr_read_num(int csr_num) >> { >> #define switchcase_csr_read(__csr_num, __val) {\ >> @@ -608,19 +618,68 @@ static void test_vm_events_overflow(void *guest_code) >> test_vm_destroy(vm); >> } >> >> -int main(void) >> +static void test_print_help(char *name) >> { >> - test_vm_basic_test(test_pmu_basic_sanity); >> - pr_info("SBI PMU basic test : PASS\n"); >> + pr_info("Usage: %s [-h] [-d ]\n", name); >> + pr_info("\t-d: Test to disable. Available tests are 'basic', 'events', 'snapshot', 'overflow'\n"); >> + pr_info("\t-h: print this help screen\n"); >> +} >> >> - test_vm_events_test(test_pmu_events); >> - pr_info("SBI PMU event verification test : PASS\n"); >> +static bool parse_args(int argc, char *argv[]) >> +{ >> + int opt; >> + >> + while ((opt = getopt(argc, argv, "hd:")) != -1) { >> + switch (opt) { >> + case 'd': >> + if (!strncmp("basic", optarg, 5)) >> + disabled_test_id = SBI_PMU_TEST_BASIC; >> + else if (!strncmp("events", optarg, 6)) >> + disabled_test_id = SBI_PMU_TEST_EVENTS; >> + else if (!strncmp("snapshot", optarg, 8)) >> + disabled_test_id = SBI_PMU_TEST_SNAPSHOT; >> + else if (!strncmp("overflow", optarg, 8)) >> + disabled_test_id = SBI_PMU_TEST_OVERFLOW; >> + else >> + goto done; >> + break; >> + break; > > Extra 'break' > Fixed. Thanks for catching this. >> + case 'h': >> + default: >> + goto done; >> + } >> + } >> >> - test_vm_events_snapshot_test(test_pmu_events_snaphost); >> - pr_info("SBI PMU event verification with snapshot test : PASS\n"); >> + return true; >> +done: >> + test_print_help(argv[0]); >> + return false; >> +} >> >> - test_vm_events_overflow(test_pmu_events_overflow); >> - pr_info("SBI PMU event verification with overflow test : PASS\n"); >> +int main(int argc, char *argv[]) >> +{ >> + if (!parse_args(argc, argv)) >> + exit(KSFT_SKIP); >> + >> + if (disabled_test_id != SBI_PMU_TEST_BASIC) { >> + test_vm_basic_test(test_pmu_basic_sanity); >> + pr_info("SBI PMU basic test : PASS\n"); >> + } >> + >> + if (disabled_test_id != SBI_PMU_TEST_EVENTS) { >> + test_vm_events_test(test_pmu_events); >> + pr_info("SBI PMU event verification test : PASS\n"); >> + } >> + >> + if (disabled_test_id != 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_test_id != SBI_PMU_TEST_OVERFLOW) { >> + test_vm_events_overflow(test_pmu_events_overflow); >> + pr_info("SBI PMU event verification with overflow test : PASS\n"); >> + } >> >> return 0; >> } >> -- >> 2.34.1 >> > > Thanks, > drew > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv