Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp690150rwd; Wed, 7 Jun 2023 05:47:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BjW03MxriAEEHx0q26Fjany7kRmCmyD8c3esKDJkzvf8e7RY7oIo3TPUyBOkNMbfR6LTD X-Received: by 2002:a05:6a00:2e01:b0:653:a9ac:44c with SMTP id fc1-20020a056a002e0100b00653a9ac044cmr2099597pfb.11.1686142068160; Wed, 07 Jun 2023 05:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686142068; cv=none; d=google.com; s=arc-20160816; b=irywkI6R5Ls7jKM7WKOmh915mNf5EPPWqBi2I27zsGStgXpQL/y6wA+l/rKrjwFq9L LfZYUJR7nBSnBHe7DL+5WxMnvq5uE13JsOcoJaaSv9sk7GaW1kCKeOW68gFTcggDl1/3 MRd0E+nJZYBFBiaUfz14ENsG+7s6UypOsX+T8UIDD81ix8qLNJGILXmZtiUbQC1PkebM Bu7YF/8E6LPcpXwg3xOIaZCpVLjh37gJLbDgfyhZ2GqAOKYrK7zbW7SfZ+rNETFRll7I mU910+DL7eFMf3ilpN9coyqmusE+3b4oJjy5Z5qLD4RJTRB65CPicLSYPn2L0QIKNbZW 3c3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vYpDm8AgCQ+Jjdrz0qWAN2s9cw9E+zpsCV8mVTUXM7c=; b=gF3cxWLf/Qz/phwilFbZtTcwG3+2RepmHJ6IxU28+a0M80RND64SHueu1nqQ7z6Fjf bCUPlWFSeqS7YSm6zVYjA2o5YgJKvSW2KN92I1W8SfWQRN5jmX53K/BRzl962dS1Q9y+ 0HWNpn2ma35aI3Fc0WuFv6i/Pz0Pz0O88ND27+adtzKCphZTVTxGm9/BwpymwFE9EYbx 8ST4wnJBGfr06aL9z+v1Kg29UTFQ94587jRjsMzneLMS/NgkKrq30XML/FXw8J1olJlk PpLc69W9n9EDCwh2vbsWmisHjOW0XsIcoWUkdfbL5PdrNid6WrM81neo5C1P+Trk3Z6U 9Dxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=i5rFskEE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020aa79722000000b0065ef9f22da9si3481374pfg.19.2023.06.07.05.47.30; Wed, 07 Jun 2023 05:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=i5rFskEE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240989AbjFGMhn (ORCPT + 99 others); Wed, 7 Jun 2023 08:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240947AbjFGMhQ (ORCPT ); Wed, 7 Jun 2023 08:37:16 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB21EE6B; Wed, 7 Jun 2023 05:37:15 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id e9e14a558f8ab-33b3cfb9495so4149705ab.2; Wed, 07 Jun 2023 05:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686141435; x=1688733435; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vYpDm8AgCQ+Jjdrz0qWAN2s9cw9E+zpsCV8mVTUXM7c=; b=i5rFskEEOgyCq5QuYFWKv28gtEf10KrrK/2fQXblBJmEV0FN88vbBP3DcNSMNbbJ5n 1baPoBt/MAUPX0UZ0rIcD7iAxP8eeAxS5efL7rWqyyxat4IhpN4mbRoFuMuj6Ez6iXPd mkPXNru6T7TaQ+VHJvnYBkGsqXU4kroiR8MxEvTPiUS3j0dS3PdsUJnJzEscHO2Prt8i e+JDEl9omKQ1Gz0mvk0MoGRYZDGT/+aX8mIvpRESv30CL21iWa4OcX/8y4A2iaCnNLbJ EtJpTAKc32s79S/MZtmwrSzbG95HIZBF8ii1gB5vBf0Wq75LnlkQaN9LwLtvBeTXLC+X FJ1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686141435; x=1688733435; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vYpDm8AgCQ+Jjdrz0qWAN2s9cw9E+zpsCV8mVTUXM7c=; b=VD+NFqOU3Ly2zs19UjG0/bERCvLnbnaE1ylUTRXJfs9aQp5coBD1vrzxEFvHug/Vpj 0Rc42H7B4MyFuTD0lpvTX4njV0Btcct5vuBw2LQe6zJ6vgiXgVoKzUOXnpiYY+Mu4neD YgV+SjeKouhUom9Ecu9W0nelhlK3TMvTL3W48wZUW6cJhCWw0/KR6gEtJu2DDxo9AwAR wH/nFOtkgnX0EiNs+trmZrBaSN6W/T3AAOokKrmdIE7LX9xC1xzhBAfU5EL91NzTd+Jz rV5Uubdnps7wqAzVaJZQT7yFz15opwlXUffV6p4jLLWd0rjO1w/QooAwoHsNPbA6HrSn /bdw== X-Gm-Message-State: AC+VfDxc2hy7aGAVYpBNMRmOCYEJIpikx5YlJrkuxMWtA3t+gZ6JYXKX PT35rDzntUMst9ek8wthjSU= X-Received: by 2002:a92:d8c9:0:b0:33d:1072:361b with SMTP id l9-20020a92d8c9000000b0033d1072361bmr6859096ilo.21.1686141435110; Wed, 07 Jun 2023 05:37:15 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id k18-20020a635a52000000b00528db73ed70sm9038904pgm.3.2023.06.07.05.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:37:14 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Like Xu , Jinrong Liang , linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/4] KVM: selftests: Improve PMU event filter settings and add test cases Date: Wed, 7 Jun 2023 20:36:56 +0800 Message-Id: <20230607123700.40229-1-cloudliang@tencent.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch series aims to improve the PMU event filter settings with a cleaner and more organized structure and adds several test cases related to PMU event filters. The first patch of this series introduces a custom "__kvm_pmu_event_filter" structure that simplifies the event filter setup and improves overall code readability and maintainability. The second patch adds test cases to check that unsupported input values in the PMU event filters are rejected, covering unsupported "action" values, unsupported "flags" values, and unsupported "nevents" values, as well as the setting of non-existent fixed counters in the fixed bitmap. The third patch includes tests for the PMU event filter's behavior when applied to fixed performance counters, ensuring the correct operation in cases where no fixed counters exist (e.g., Intel guest PMU version=1 or AMD guest). Finally, the fourth patch adds a test to verify that setting both generic and fixed performance event filters does not impact the consistency of the fixed performance filter behavior. These changes help to ensure that KVM's PMU event filter functions as expected in all supported use cases. These patches have been tested and verified to function properly. Any feedback or suggestions are greatly appreciated. Please note that following patches should be applied before this patch series: https://lore.kernel.org/kvm/20230530134248.23998-2-cloudliang@tencent.com https://lore.kernel.org/kvm/20230530134248.23998-3-cloudliang@tencent.com This will ensure that macro definitions such as X86_INTEL_MAX_FIXED_CTR_NUM, INTEL_PMC_IDX_FIXED, etc. can be used. Sincerely, Jinrong Liang Changes log: v3: - Rebased to 31b4fc3bc64a(tag: kvm-x86-next-2023.06.02). - Dropped the patch "KVM: selftests: Replace int with uint32_t for nevents". (Sean) - Dropped the patch "KVM: selftests: Test pmu event filter with incompatible kvm_pmu_event_filter". (Sean) - Introduce __kvm_pmu_event_filter to replace the original method of creating PMU event filters. (Sean) - Use the macro definition of kvm_cpu_property to find the number of supported fixed counters instead of calculating it via the vcpu's cpuid. (Sean) - Remove the wrappers that are single line passthroughs. (Sean) - Optimize function names and variable names. (Sean) - Optimize comments to make them more rigorous. (Sean) v2: - Wrap the code from the documentation in a block of code. (Bagas Sanjaya) v1: https://lore.kernel.org/kvm/20230414110056.19665-1-cloudliang@tencent.com Jinrong Liang (4): KVM: selftests: Introduce __kvm_pmu_event_filter to improved event filter settings KVM: selftests: Test unavailable event filters are rejected KVM: selftests: Check if event filter meets expectations on fixed counters KVM: selftests: Test gp event filters don't affect fixed event filters .../kvm/x86_64/pmu_event_filter_test.c | 341 +++++++++++++----- 1 file changed, 246 insertions(+), 95 deletions(-) base-commit: 31b4fc3bc64aadd660c5bfa5178c86a7ba61e0f7 prerequisite-patch-id: 909d42f185f596d6e5c5b48b33231c89fa5236e4 prerequisite-patch-id: ba0dd0f97d8db0fb6cdf2c7f1e3a60c206fc9784 -- 2.31.1