Skip to contentSkip to conversation

virt-test: Add a class NumaNode v2

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Dec 9, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virt-test: Add a class NumaNode v2

From: Amos Kong <[email protected]>

Dynamically checking hardware, use a dict to record the pin status, pin process to single cpu by 'taskset' command.

Guest memory pining is already implemented in framework. process pining needs to be done in the testcases.

Example:

|  numa_node = -1 # last node
|  p = virt_utils.NumaNode(numa_node)
|  vhost_threads = commands.getoutput("ps aux |grep '\[vhost-.*\]'
|                  |grep -v grep|awk '{print $2}'")
|  for i in vhost_threads.split():
|      logging.debug("pin vhost_net thread(%s) to host cpu node" % i)
|      p.pin_cpu(i)
|  o = vm.monitor.info("cpus")
|  for i in re.findall("thread_id=(\d+)", o):
|      logging.debug("pin vcpu thread(%s) to host cpu node" % i)
|      p.pin_cpu(i)
|  p.show()

Changes from v1:
* Removed usage of commands API, using utils.run() instead
* Added unittests for NumaNode
* Improved docstrings

---
 client/tests/kvm/base.cfg.sample   |    6 ++-
 client/virt/kvm_vm.py              |    8 +++
 client/virt/virt_utils.py          |   80 +++++++++++++++++++++++++
 client/virt/virt_utils_unittest.py |  112 +++++++++++++++++++++++++++++++++++-
 4 files changed, 204 insertions(+), 2 deletions(-)
client/tests/kvm/base.cfg.sample +5 -1
index 21fa513..411decf 100644
@@ -147,6 +147,11 @@ shell_port = 22
 used_cpus = 1
 used_mem = 512
 
+# Numa pinning params
+# pin guest memory to 1st numa node
+# pin processes to host cpu of 1st node
+# numa_node = 1
+
 # Port redirections
 redirs = remote_shell
 guest_port_remote_shell = 22
@@ -159,4 +164,3 @@ login_timeout = 360
 
 # NFS directory of guest images
 images_good = fileserver.foo.com:/autotest/images_good
-
client/virt/kvm_vm.py +8 -0
index 6747c2b..fa258c3 100644
@@ -473,6 +473,14 @@ class VM(virt_vm.BaseVM):
             qemu_cmd += "LD_LIBRARY_PATH=%s " % library_path
         if params.get("qemu_audio_drv"):
             qemu_cmd += "QEMU_AUDIO_DRV=%s " % params.get("qemu_audio_drv")
+        # Add numa memory cmd to pin guest memory to numa node
+        if params.get("numa_node"):
+            numa_node = int(params.get("numa_node"))
+            if numa_node < 0:
+                p = virt_utils.NumaNode(numa_node)
+                qemu_cmd += "numactl -m %s " % (int(p.get_node_num()) + numa_node)
+            else:
+                qemu_cmd += "numactl -m %s " % (numa_node - 1)
         # Add the qemu binary
         qemu_cmd += qemu_binary
         # Add the VM's name
client/virt/virt_utils.py +80 -0

83 lines not on this page · raw message

client/virt/virt_utils_unittest.py +111 -1

124 lines not on this page · raw message

Signature · 1 line
1.7.7.3