public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: <avi@redhat.com>, <anthony@codemonkey.ws>
Cc: <kvm@vger.kernel.org>, Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH 3/4] NUMA: parse new host dependent command line options
Date: Wed, 11 Aug 2010 15:52:17 +0200	[thread overview]
Message-ID: <1281534738-8310-4-git-send-email-andre.przywara@amd.com> (raw)
In-Reply-To: <1281534738-8310-1-git-send-email-andre.przywara@amd.com>

To separate the host and the guest NUMA part the host NUMA options
can be specified separately from the guest ones.
Mimicing numactl's syntax the parser allows to specify the NUMA
binding policy for each guest node. It supports membind, interleave
and preferred together with negation (!) and CPUSET relative
addressing (+). Since the comma is already used by the QEMU
command line interpreter, it cannot be used here to enumerate
host nodes (but '-' is supported). Example:
$ qemu ... -numa node -numa host,nodeid=0,interleave=+0-1
(uses interleaving on the first two nodes belonging to the current
CPUSET for the one guest node)
$ qemu ... -numa node -numa node -numa host,nodeid=0,membind=3 \
  -numa host,nodeid=1,preferred=!2-3
(binding the first guest node to host node 3 and the second guest
node to any node expect 2 and 3)

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
---
 sysemu.h |    8 ++++++++
 vl.c     |   25 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/sysemu.h b/sysemu.h
index e5f88d1..52fedd4 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -140,10 +140,18 @@ extern long hpagesize;
 #ifndef MAX_NUMA_VCPUS
 #define MAX_NUMA_VCPUS 256
 #endif
+#define NODE_HOST_NONE        0x00
+#define NODE_HOST_BIND        0x01
+#define NODE_HOST_INTERLEAVE  0x02
+#define NODE_HOST_PREFERRED   0x03
+#define NODE_HOST_POLICY_MASK 0x03
+#define NODE_HOST_RELATIVE    0x04
 extern int nb_numa_nodes;
 struct numa_info {
     uint64_t guest_mem;
     DECLARE_BITMAP(guest_cpu, MAX_NUMA_VCPUS);
+    DECLARE_BITMAP(host_mem, MAX_NUMA_VCPUS);
+    unsigned int flags;
 };
 extern struct numa_info numa_info[MAX_NODES];
 
diff --git a/vl.c b/vl.c
index 40fac59..6df9cc9 100644
--- a/vl.c
+++ b/vl.c
@@ -792,6 +792,29 @@ static void numa_add(const char *optarg)
             parse_bitmap(option, numa_info[nodenr].guest_cpu, MAX_NUMA_VCPUS);
         }
         nb_numa_nodes++;
+    } else if (!strcmp(option, "host")) {
+        if (get_param_value(option, 128, "nodeid", optarg) == 0) {
+            fprintf(stderr, "error: need nodeid for -numa host,...\n");
+            exit(1);
+        }
+        nodenr = strtoull(option, NULL, 10);
+        if (nodenr >= nb_numa_nodes) {
+            fprintf(stderr, "nodeid exceeds specified NUMA nodes\n");
+           	exit(1);
+        }
+        numa_info[nodenr].flags = NODE_HOST_NONE;
+        option[0] = 0;
+        if (get_param_value(option, 128, "interleave", optarg) != 0)
+            numa_info[nodenr].flags |= NODE_HOST_INTERLEAVE;
+        else if (get_param_value(option, 128, "preferred", optarg) != 0)
+            numa_info[nodenr].flags |= NODE_HOST_PREFERRED;
+        else if (get_param_value(option, 128, "membind", optarg) != 0)
+            numa_info[nodenr].flags |= NODE_HOST_BIND;
+        if (option[0] != 0) {
+            if (parse_bitmap(option, numa_info[nodenr].host_mem,
+                MAX_NUMA_VCPUS) & 1)
+                numa_info[nodenr].flags |= NODE_HOST_RELATIVE;
+        }
     }
     return;
 }
@@ -1895,6 +1918,8 @@ int main(int argc, char **argv, char **envp)
     for (i = 0; i < MAX_NODES; i++) {
         numa_info[i].guest_mem = 0;
         bitmap_zero(numa_info[i].guest_cpu, MAX_NUMA_VCPUS);
+        bitmap_zero(numa_info[i].host_mem, MAX_NUMA_VCPUS);
+        numa_info[i].flags = NODE_HOST_NONE;
     }
 
     assigned_devices_index = 0;
-- 
1.6.4



  parent reply	other threads:[~2010-08-11 13:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11 13:52 [PATCH 0/4]: NUMA: add host binding Andre Przywara
2010-08-11 13:52 ` [PATCH 1/4] NUMA: change existing NUMA guest code to use new bitmap implementation Andre Przywara
2010-08-11 13:52 ` [PATCH 2/4] NUMA: add Linux libnuma detection Andre Przywara
2010-08-11 13:52 ` Andre Przywara [this message]
2010-08-11 13:52 ` [PATCH 4/4] NUMA: realize NUMA memory pinning Andre Przywara
2010-08-23 18:59   ` Marcelo Tosatti
2010-08-23 19:27     ` Anthony Liguori
2010-08-23 21:16       ` Andre Przywara
2010-08-23 21:27         ` Anthony Liguori
2010-08-31 20:54           ` Andrew Theurer
2010-08-31 22:03             ` Anthony Liguori
2010-09-01  3:38               ` Andrew Theurer
2010-09-09 20:00               ` Andre Przywara

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=1281534738-8310-4-git-send-email-andre.przywara@amd.com \
    --to=andre.przywara@amd.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=kvm@vger.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