Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Manali Shukla <manali.shukla@amd.com>
To: <kvm@vger.kernel.org>, <linux-kselftest@vger.kernel.org>
Cc: <pbonzini@redhat.com>, <seanjc@google.com>, <shuah@kernel.org>,
	<nikunj@amd.com>, <manali.shukla@amd.com>
Subject: [PATCH v1 4/4] KVM: selftests: Replace previously used vm_get_stat() to macro
Date: Mon, 21 Oct 2024 06:22:26 +0000	[thread overview]
Message-ID: <20241021062226.108657-5-manali.shukla@amd.com> (raw)
In-Reply-To: <20241021062226.108657-1-manali.shukla@amd.com>

Previous patch converts vm_get_stat() to macro and adds a concatenation
trickery to generate compilation error if the stat doesn't exist.

Improve nx_huge_pages_test.c and dirty_log_page_splitting_test.c based
on the macro.

Compile tested both the selftests.

Signed-off-by: Manali Shukla <manali.shukla@amd.com>
---
 .../selftests/kvm/x86_64/dirty_log_page_splitting_test.c    | 6 +++---
 tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c     | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c b/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c
index 2929c067c207..b0d2b04a7ff2 100644
--- a/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c
+++ b/tools/testing/selftests/kvm/x86_64/dirty_log_page_splitting_test.c
@@ -41,9 +41,9 @@ struct kvm_page_stats {
 
 static void get_page_stats(struct kvm_vm *vm, struct kvm_page_stats *stats, const char *stage)
 {
-	stats->pages_4k = vm_get_stat(vm, "pages_4k");
-	stats->pages_2m = vm_get_stat(vm, "pages_2m");
-	stats->pages_1g = vm_get_stat(vm, "pages_1g");
+	stats->pages_4k = vm_get_stat(vm, pages_4k);
+	stats->pages_2m = vm_get_stat(vm, pages_2m);
+	stats->pages_1g = vm_get_stat(vm, pages_1g);
 	stats->hugepages = stats->pages_2m + stats->pages_1g;
 
 	pr_debug("\nPage stats after %s: 4K: %ld 2M: %ld 1G: %ld huge: %ld\n",
diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
index e7efb2b35f8b..c0d84827f736 100644
--- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
@@ -73,7 +73,7 @@ static void check_2m_page_count(struct kvm_vm *vm, int expected_pages_2m)
 {
 	int actual_pages_2m;
 
-	actual_pages_2m = vm_get_stat(vm, "pages_2m");
+	actual_pages_2m = vm_get_stat(vm, pages_2m);
 
 	TEST_ASSERT(actual_pages_2m == expected_pages_2m,
 		    "Unexpected 2m page count. Expected %d, got %d",
@@ -84,7 +84,7 @@ static void check_split_count(struct kvm_vm *vm, int expected_splits)
 {
 	int actual_splits;
 
-	actual_splits = vm_get_stat(vm, "nx_lpage_splits");
+	actual_splits = vm_get_stat(vm, nx_lpage_splits);
 
 	TEST_ASSERT(actual_splits == expected_splits,
 		    "Unexpected NX huge page split count. Expected %d, got %d",
-- 
2.34.1


  parent reply	other threads:[~2024-10-21  6:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21  6:22 [PATCH v1 0/4] KVM selftests enhancements Manali Shukla
2024-10-21  6:22 ` [PATCH v1 1/4] KVM: selftests: Add safe_halt() and cli() helpers to common code Manali Shukla
2024-12-19 17:39   ` Sean Christopherson
2024-10-21  6:22 ` [PATCH v1 2/4] KVM: selftests: Add an interface to read the data of named vcpu stat Manali Shukla
2024-12-20  0:35   ` Sean Christopherson
2024-10-21  6:22 ` [PATCH v1 3/4] KVM: selftests: convert vm_get_stat to macro Manali Shukla
2024-10-21  6:22 ` Manali Shukla [this message]
2024-12-20  0:42   ` [PATCH v1 4/4] KVM: selftests: Replace previously used vm_get_stat() " Sean Christopherson
2024-11-28 15:06 ` [PATCH v1 0/4] KVM selftests enhancements Manali Shukla
2024-12-20  0:52 ` Sean Christopherson

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=20241021062226.108657-5-manali.shukla@amd.com \
    --to=manali.shukla@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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