From: Vipin Sharma <vipinsh@google.com>
To: seanjc@google.com, pbonzini@redhat.com, dmatlack@google.com
Cc: andrew.jones@linux.dev, wei.w.wang@intel.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Vipin Sharma <vipinsh@google.com>
Subject: [PATCH v8 4/7] KVM: selftests: Use SZ_1G from sizes.h in max_guest_memory_test.c
Date: Wed, 2 Nov 2022 16:27:34 -0700 [thread overview]
Message-ID: <20221102232737.1351745-5-vipinsh@google.com> (raw)
In-Reply-To: <20221102232737.1351745-1-vipinsh@google.com>
Replace size_1gb defined in max_guest_memory_test.c with the SZ_1G from
linux/sizes.h header file.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
---
.../selftests/kvm/max_guest_memory_test.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c
index 1595b73dc09a..8056dc5831b5 100644
--- a/tools/testing/selftests/kvm/max_guest_memory_test.c
+++ b/tools/testing/selftests/kvm/max_guest_memory_test.c
@@ -11,6 +11,7 @@
#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/atomic.h>
+#include <linux/sizes.h>
#include "kvm_util.h"
#include "test_util.h"
@@ -162,8 +163,7 @@ int main(int argc, char *argv[])
* just below the 4gb boundary. This test could create memory at
* 1gb-3gb,but it's simpler to skip straight to 4gb.
*/
- const uint64_t size_1gb = (1 << 30);
- const uint64_t start_gpa = (4ull * size_1gb);
+ const uint64_t start_gpa = SZ_4G;
const int first_slot = 1;
struct timespec time_start, time_run1, time_reset, time_run2;
@@ -180,13 +180,13 @@ int main(int argc, char *argv[])
* are quite common for x86, requires changing only max_mem (KVM allows
* 32k memslots, 32k * 2gb == ~64tb of guest memory).
*/
- slot_size = 2 * size_1gb;
+ slot_size = SZ_2G;
max_slots = kvm_check_cap(KVM_CAP_NR_MEMSLOTS);
TEST_ASSERT(max_slots > first_slot, "KVM is broken");
/* All KVM MMUs should be able to survive a 128gb guest. */
- max_mem = 128 * size_1gb;
+ max_mem = 128ull * SZ_1G;
calc_default_nr_vcpus();
@@ -197,11 +197,11 @@ int main(int argc, char *argv[])
TEST_ASSERT(nr_vcpus > 0, "number of vcpus must be >0");
break;
case 'm':
- max_mem = atoi_paranoid(optarg) * size_1gb;
+ max_mem = 1ull * atoi_paranoid(optarg) * SZ_1G;
TEST_ASSERT(max_mem > 0, "memory size must be >0");
break;
case 's':
- slot_size = atoi_paranoid(optarg) * size_1gb;
+ slot_size = 1ull * atoi_paranoid(optarg) * SZ_1G;
TEST_ASSERT(slot_size > 0, "slot size must be >0");
break;
case 'H':
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
#ifdef __x86_64__
/* Identity map memory in the guest using 1gb pages. */
- for (i = 0; i < slot_size; i += size_1gb)
+ for (i = 0; i < slot_size; i += SZ_1G)
__virt_pg_map(vm, gpa + i, gpa + i, PG_LEVEL_1G);
#else
for (i = 0; i < slot_size; i += vm->page_size)
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
vcpus = NULL;
pr_info("Running with %lugb of guest memory and %u vCPUs\n",
- (gpa - start_gpa) / size_1gb, nr_vcpus);
+ (gpa - start_gpa) / SZ_1G, nr_vcpus);
rendezvous_with_vcpus(&time_start, "spawning");
rendezvous_with_vcpus(&time_run1, "run 1");
--
2.38.1.273.g43a17bfeac-goog
next prev parent reply other threads:[~2022-11-02 23:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 23:27 [PATCH v8 0/7] dirty_log_perf_test vCPU pinning Vipin Sharma
2022-11-02 23:27 ` [PATCH v8 1/7] KVM: selftests: Add missing break between -e and -g option in dirty_log_perf_test Vipin Sharma
2022-11-02 23:27 ` [PATCH v8 2/7] KVM: selftests: Put command line options in alphabetical order " Vipin Sharma
2022-11-02 23:27 ` [PATCH v8 3/7] KVM: selftests: Add atoi_paranoid() to catch errors missed by atoi() Vipin Sharma
2022-11-03 0:18 ` Sean Christopherson
2022-11-02 23:27 ` Vipin Sharma [this message]
2022-11-02 23:44 ` [PATCH v8 4/7] KVM: selftests: Use SZ_1G from sizes.h in max_guest_memory_test.c Sean Christopherson
2022-11-02 23:27 ` [PATCH v8 5/7] KVM: selftests: Shorten the test args in memslot_modification_stress_test.c Vipin Sharma
2022-11-02 23:45 ` Sean Christopherson
2022-11-03 0:16 ` Sean Christopherson
2022-11-03 18:56 ` Vipin Sharma
2022-11-02 23:27 ` [PATCH v8 6/7] KVM: selftests: Add atoi_positive() and atoi_non_negative() for input validation Vipin Sharma
2022-11-03 0:17 ` Sean Christopherson
2022-11-02 23:27 ` [PATCH v8 7/7] KVM: selftests: Allowing running dirty_log_perf_test on specific CPUs Vipin Sharma
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=20221102232737.1351745-5-vipinsh@google.com \
--to=vipinsh@google.com \
--cc=andrew.jones@linux.dev \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=wei.w.wang@intel.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®