public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH 3/3 kvm-unit-tests] dirty-log-perf: Take slot size from command line
Date: Sun, 15 Jan 2012 12:45:56 +0900	[thread overview]
Message-ID: <20120115124556.34d35a56b699f384b25af728@gmail.com> (raw)
In-Reply-To: <20120115124131.3b460d1d85194edaa251e635@gmail.com>

Dirty logging is used both for VGA, small slot, and live migration,
large slot, so make the slot size changeable as follows:

  $ ./api/dirty-log-perf -n 8K
  dirty-log-perf: 8192 slot pages / 262144 mem pages

Note: though we can also change the size of the entire memory space, by
using -m, we observed that this test did not work well under the
following condition:

  16 < nr_total_pages < 221K

But thinking that we sometimes want to test slots larger than the
default, we have decided to keep the option.

Signed-off-by: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
---
 api/dirty-log-perf.cc |   54 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/api/dirty-log-perf.cc b/api/dirty-log-perf.cc
index f48bc95..ada831e 100644
--- a/api/dirty-log-perf.cc
+++ b/api/dirty-log-perf.cc
@@ -8,9 +8,9 @@
 
 namespace {
 
-const int page_size		= 4096;
-const int64_t nr_total_pages	= 256 * 1024;
-const int64_t nr_slot_pages	= 256 * 1024;
+const int page_size	= 4096;
+int64_t nr_total_pages	= 256 * 1024;
+int64_t nr_slot_pages	= 256 * 1024;
 
 // Return the current time in nanoseconds.
 uint64_t time_ns()
@@ -67,12 +67,58 @@ void check_dirty_log(kvm::vcpu& vcpu, mem_slot& slot, void* slot_head)
 
 }
 
+void parse_options(int ac, char **av)
+{
+    int opt;
+    char *endptr;
+
+    while ((opt = getopt(ac, av, "n:m:")) != -1) {
+        switch (opt) {
+        case 'n':
+            errno = 0;
+            nr_slot_pages = strtol(optarg, &endptr, 10);
+            if (errno || endptr == optarg) {
+                printf("dirty-log-perf: Invalid number: -n %s\n", optarg);
+                exit(1);
+            }
+            if (*endptr == 'k' || *endptr == 'K') {
+                nr_slot_pages *= 1024;
+            }
+            break;
+        case 'm':
+            errno = 0;
+            nr_total_pages = strtol(optarg, &endptr, 10);
+            if (errno || endptr == optarg) {
+                printf("dirty-log-perf: Invalid number: -m %s\n", optarg);
+                exit(1);
+            }
+            if (*endptr == 'k' || *endptr == 'K') {
+                nr_total_pages *= 1024;
+            }
+            break;
+        default:
+            printf("dirty-log-perf: Invalid option\n");
+            exit(1);
+        }
+    }
+
+    if (nr_slot_pages > nr_total_pages) {
+        printf("dirty-log-perf: Invalid setting: slot %lld > mem %lld\n",
+               nr_slot_pages, nr_total_pages);
+        exit(1);
+    }
+    printf("dirty-log-perf: %lld slot pages / %lld mem pages\n",
+           nr_slot_pages, nr_total_pages);
+}
+
 int main(int ac, char **av)
 {
     kvm::system sys;
     kvm::vm vm(sys);
     mem_map memmap(vm);
 
+    parse_options(ac, av);
+
     void* mem_head;
     int64_t mem_size = nr_total_pages * page_size;
     if (posix_memalign(&mem_head, page_size, mem_size)) {
@@ -86,8 +132,8 @@ int main(int ac, char **av)
     kvm::vcpu vcpu(vm, 0);
 
     uint64_t slot_size = nr_slot_pages * page_size;
-    uint64_t next_addr = mem_addr + slot_size;
     uint64_t next_size = mem_size - slot_size;
+    uint64_t next_addr = mem_addr + slot_size;
     mem_slot slot(memmap, mem_addr, slot_size, mem_head);
     mem_slot other_slot(memmap, next_addr, next_size, (void *)next_addr);
 
-- 
1.7.5.4


  parent reply	other threads:[~2012-01-15  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15  3:41 [PATCH 0/3 kvm-unit-tests] Dirty logging performance test Takuya Yoshikawa
2012-01-15  3:43 ` [PATCH v2 1/3 kvm-unit-tests] Add dirty " Takuya Yoshikawa
2012-01-15  3:44 ` [PATCH 2/3 kvm-unit-tests] dirty-log-perf: Split guest memory into two slots Takuya Yoshikawa
2012-01-15  3:45 ` Takuya Yoshikawa [this message]
2012-01-18 13:50 ` [PATCH 0/3 kvm-unit-tests] Dirty logging performance test Marcelo Tosatti

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=20120115124556.34d35a56b699f384b25af728@gmail.com \
    --to=takuya.yoshikawa@gmail.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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