All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yanan Wang <wangyanan55@huawei.com>
To: <kvm@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	"Andrew Jones" <drjones@redhat.com>,
	Marc Zyngier <maz@kernel.org>, Ben Gardon <bgardon@google.com>,
	Peter Xu <peterx@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Aaron Lewis <aaronlewis@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	<wanghaibin.wang@huawei.com>, <yuzenghui@huawei.com>,
	Yanan Wang <wangyanan55@huawei.com>
Subject: [RFC PATCH 1/2] KVM: selftests: Add a macro to get string of vm_mem_backing_src_type
Date: Mon, 8 Feb 2021 17:08:40 +0800	[thread overview]
Message-ID: <20210208090841.333724-2-wangyanan55@huawei.com> (raw)
In-Reply-To: <20210208090841.333724-1-wangyanan55@huawei.com>

Add a macro to get string of the backing source memory type, so that
application can add choices for source types in the help() function,
and users can specify which type to use for testing.

Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
---
 tools/testing/selftests/kvm/include/kvm_util.h | 3 +++
 tools/testing/selftests/kvm/lib/kvm_util.c     | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index 5cbb861525ed..f5fc29dc9ee6 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -69,7 +69,9 @@ enum vm_guest_mode {
 #define PTES_PER_MIN_PAGE	ptes_per_page(MIN_PAGE_SIZE)
 
 #define vm_guest_mode_string(m) vm_guest_mode_string[m]
+#define vm_mem_backing_src_type_string(s) vm_mem_backing_src_type_string[s]
 extern const char * const vm_guest_mode_string[];
+extern const char * const vm_mem_backing_src_type_string[];
 
 struct vm_guest_mode_params {
 	unsigned int pa_bits;
@@ -83,6 +85,7 @@ enum vm_mem_backing_src_type {
 	VM_MEM_SRC_ANONYMOUS,
 	VM_MEM_SRC_ANONYMOUS_THP,
 	VM_MEM_SRC_ANONYMOUS_HUGETLB,
+	NUM_VM_BACKING_SRC_TYPES,
 };
 
 int kvm_check_cap(long cap);
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index fa5a90e6c6f0..a9b651c7f866 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -165,6 +165,14 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = {
 _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES,
 	       "Missing new mode params?");
 
+const char * const vm_mem_backing_src_type_string[] = {
+	"VM_MEM_SRC_ANONYMOUS        ",
+	"VM_MEM_SRC_ANONYMOUS_THP    ",
+	"VM_MEM_SRC_ANONYMOUS_HUGETLB",
+};
+_Static_assert(sizeof(vm_mem_backing_src_type_string)/sizeof(char *) == NUM_VM_BACKING_SRC_TYPES,
+	       "Missing new source type strings?");
+
 /*
  * VM Create
  *
-- 
2.23.0


  reply	other threads:[~2021-02-08  9:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  9:08 [RFC PATCH 0/2] Add a test for kvm page table code Yanan Wang
2021-02-08  9:08 ` Yanan Wang [this message]
2021-02-08 17:43   ` [RFC PATCH 1/2] KVM: selftests: Add a macro to get string of vm_mem_backing_src_type Sean Christopherson
2021-02-09 10:43     ` wangyanan (Y)
2021-02-08 18:13   ` Ben Gardon
2021-02-09 11:21     ` wangyanan (Y)
2021-02-09 17:18       ` Ben Gardon
2021-02-09 17:35         ` Sean Christopherson
2021-02-10  4:11           ` wangyanan (Y)
2021-02-08  9:08 ` [RFC PATCH 2/2] KVM: selftests: Add a test for kvm page table code Yanan Wang
2021-02-08 10:21   ` Vitaly Kuznetsov
2021-02-09  4:34     ` wangyanan (Y)
2021-02-08 20:29   ` Ben Gardon
2021-02-09  7:21     ` wangyanan (Y)
2021-02-09 17:38       ` Ben Gardon
2021-02-10  5:13         ` wangyanan (Y)
2021-02-09  9:43     ` wangyanan (Y)
2021-02-09 17:57       ` Ben Gardon
2021-02-10  9:36         ` wangyanan (Y)

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=20210208090841.333724-2-wangyanan55@huawei.com \
    --to=wangyanan55@huawei.com \
    --cc=aaronlewis@google.com \
    --cc=bgardon@google.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=vkuznets@redhat.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yuzenghui@huawei.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.