From: Gavin Shan <gshan@redhat.com>
To: kvmarm@lists.linux.dev
Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, ajones@ventanamicro.com,
pbonzini@redhat.com, maz@kernel.org, shuah@kernel.org,
oliver.upton@linux.dev, mail@maciej.szmigiero.name,
maciej.szmigiero@oracle.com, seanjc@google.com,
peterx@redhat.com, ricarkol@google.com, zhenyzha@redhat.com,
shan.gavin@gmail.com
Subject: [PATCH v2 5/6] KVM: selftests: memslot_perf_test: Consolidate memory sizes
Date: Tue, 18 Oct 2022 12:04:53 +0800 [thread overview]
Message-ID: <20221018040454.405719-6-gshan@redhat.com> (raw)
In-Reply-To: <20221018040454.405719-1-gshan@redhat.com>
The addresses and sizes passed to vm_userspace_mem_region_add() and
madvise() should be aligned to host page size, which can be 64KB on
aarch64. So it's wrong by passing additional fixed 4KB memory area
to various tests.
Fix it by passing additional fixed 64KB memory area to various tests. We
also add checks to ensure that none of host/guest page size exceeds 64KB.
After it's applied, the following command works fine on 64KB-page-size-host
and 4KB-page-size-guest.
# ./memslot_perf_test -v -s 512
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
.../selftests/kvm/include/kvm_util_base.h | 15 ++++++++++
.../testing/selftests/kvm/memslot_perf_test.c | 30 ++++++++++++-------
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index e42a09cd24a0..bd9a19b9054b 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -26,6 +26,21 @@
#define NSEC_PER_SEC 1000000000L
+#define SIZE_KiB (1UL << 10)
+#define SIZE_MiB (1UL << 20)
+#define SIZE_GiB (1UL << 30)
+#define SIZE_TiB (1UL << 40)
+
+/* Base and huge page size */
+#define SIZE_4KiB (4 * SIZE_KiB)
+#define SIZE_16KiB (16 * SIZE_KiB)
+#define SIZE_64KiB (64 * SIZE_KiB)
+#define SIZE_2MiB (2 * SIZE_MiB)
+#define SIZE_32MiB (32 * SIZE_MiB)
+#define SIZE_512MiB (512 * SIZE_MiB)
+#define SIZE_1GiB (1 * SIZE_GiB)
+#define SIZE_16GiB (16 * SIZE_GiB)
+
typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */
typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c
index 78a481501ec4..3ab385e40bc0 100644
--- a/tools/testing/selftests/kvm/memslot_perf_test.c
+++ b/tools/testing/selftests/kvm/memslot_perf_test.c
@@ -25,12 +25,14 @@
#include <kvm_util.h>
#include <processor.h>
-#define MEM_SIZE ((512U << 20) + 4096)
-#define MEM_GPA 0x10000000UL
+#define MEM_EXTRA_SIZE SIZE_64KiB
+
+#define MEM_SIZE (SIZE_512MiB + MEM_EXTRA_SIZE)
+#define MEM_GPA (256 * SIZE_MiB)
#define MEM_AUX_GPA MEM_GPA
#define MEM_SYNC_GPA MEM_AUX_GPA
-#define MEM_TEST_GPA (MEM_AUX_GPA + 4096)
-#define MEM_TEST_SIZE (MEM_SIZE - 4096)
+#define MEM_TEST_GPA (MEM_AUX_GPA + MEM_EXTRA_SIZE)
+#define MEM_TEST_SIZE (MEM_SIZE - MEM_EXTRA_SIZE)
/*
* 32 MiB is max size that gets well over 100 iterations on 509 slots.
@@ -38,8 +40,8 @@
* 8194 slots in use can then be tested (although with slightly
* limited resolution).
*/
-#define MEM_SIZE_MAP ((32U << 20) + 4096)
-#define MEM_TEST_MAP_SIZE (MEM_SIZE_MAP - 4096)
+#define MEM_SIZE_MAP (SIZE_32MiB + MEM_EXTRA_SIZE)
+#define MEM_TEST_MAP_SIZE (MEM_SIZE_MAP - MEM_EXTRA_SIZE)
/*
* 128 MiB is min size that fills 32k slots with at least one page in each
@@ -47,8 +49,8 @@
*
* 2 MiB chunk size like a typical huge page
*/
-#define MEM_TEST_UNMAP_SIZE (128U << 20)
-#define MEM_TEST_UNMAP_CHUNK_SIZE (2U << 20)
+#define MEM_TEST_UNMAP_SIZE (128 * SIZE_MiB)
+#define MEM_TEST_UNMAP_CHUNK_SIZE SIZE_2MiB
/*
* For the move active test the middle of the test area is placed on
@@ -60,7 +62,7 @@
* last slot contains 100KB memory with the remaining 84KB. Hence,
* the maximum size is double of that (200KB)
*/
-#define MEM_TEST_MOVE_SIZE 0x32000
+#define MEM_TEST_MOVE_SIZE (200 * SIZE_KiB)
#define MEM_TEST_MOVE_GPA_DEST (MEM_GPA + MEM_SIZE)
static_assert(MEM_TEST_MOVE_SIZE <= MEM_TEST_SIZE,
"invalid move test region size");
@@ -799,13 +801,13 @@ static const struct test_data tests[] = {
},
{
.name = "unmap",
- .mem_size = MEM_TEST_UNMAP_SIZE + 4096,
+ .mem_size = MEM_TEST_UNMAP_SIZE + MEM_EXTRA_SIZE,
.guest_code = guest_code_test_memslot_unmap,
.loop = test_memslot_unmap_loop,
},
{
.name = "unmap chunked",
- .mem_size = MEM_TEST_UNMAP_SIZE + 4096,
+ .mem_size = MEM_TEST_UNMAP_SIZE + MEM_EXTRA_SIZE,
.guest_code = guest_code_test_memslot_unmap,
.loop = test_memslot_unmap_loop_chunked,
},
@@ -865,8 +867,14 @@ static void help(char *name, struct test_args *targs)
static bool check_memory_sizes(void)
{
+ uint32_t host_page_size = getpagesize();
uint32_t guest_page_size = vm_guest_mode_params[VM_MODE_DEFAULT].page_size;
+ if (host_page_size > SIZE_64KiB || guest_page_size > SIZE_64KiB) {
+ pr_info("Unsupported page size on host (0x%x) or guest (0x%x)\n",
+ host_page_size, guest_page_size);
+ }
+
if (MEM_SIZE % guest_page_size ||
MEM_TEST_SIZE % guest_page_size) {
pr_info("invalid MEM_SIZE or MEM_TEST_SIZE\n");
--
2.23.0
next prev parent reply other threads:[~2022-10-18 4:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 4:04 [PATCH v2 0/6] KVM: selftests: memslot_perf_test: aarch64 cleanup/fixes Gavin Shan
2022-10-18 4:04 ` [PATCH v2 1/6] KVM: selftests: memslot_perf_test: Use data->nslots in prepare_vm() Gavin Shan
2022-10-18 4:04 ` [PATCH v2 2/6] KVM: selftests: memslot_perf_test: Consolidate loop conditions " Gavin Shan
2022-10-18 4:04 ` [PATCH v2 3/6] KVM: selftests: memslot_perf_test: Probe memory slots for once Gavin Shan
2022-10-18 4:04 ` [PATCH v2 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size Gavin Shan
2022-10-18 4:04 ` Gavin Shan [this message]
2022-10-18 4:04 ` [PATCH v2 6/6] KVM: selftests: memslot_perf_test: Report optimal memory slots Gavin Shan
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=20221018040454.405719-6-gshan@redhat.com \
--to=gshan@redhat.com \
--cc=ajones@ventanamicro.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=kvmarm@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.szmigiero@oracle.com \
--cc=mail@maciej.szmigiero.name \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=ricarkol@google.com \
--cc=seanjc@google.com \
--cc=shan.gavin@gmail.com \
--cc=shuah@kernel.org \
--cc=zhenyzha@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®