test suite reviews and discussions
 help / color / mirror / Atom feed
From: Wei Ling <weix.ling@intel.com>
To: dts@dpdk.org
Cc: Wei Ling <weix.ling@intel.com>
Subject: [dts][PATCH V1 1/2] framework/qemu_kvm: support pin VM's thread to vhost CPU lcore
Date: Fri,  2 Dec 2022 12:33:37 +0800	[thread overview]
Message-ID: <20221202043337.1179691-1-weix.ling@intel.com> (raw)

Support pin VM's thread to vhost CPU lcore.

Signed-off-by: Wei Ling <weix.ling@intel.com>
---
 framework/qemu_kvm.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 20aa8008..d4f67e30 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -1365,7 +1365,7 @@ class QEMUKvm(VirtBase):
 
             self.migrate_port = int(m.group(1))
 
-    def _start_vm(self):
+    def _start_vm(self, pin_threads=True):
         """
         Start VM.
         """
@@ -1377,6 +1377,11 @@ class QEMUKvm(VirtBase):
 
         self.__get_pci_mapping()
 
+        # pin VM threads with host CPU cores
+        if pin_threads:
+            lcores = self.vcpus_pinned_to_vm.split(" ")
+            self.pin_threads(lcores=lcores)
+
         # query status
         self.update_status()
 
@@ -1385,7 +1390,7 @@ class QEMUKvm(VirtBase):
 
         # when vm is waiting for migration, can't ping
         if self.vm_status is not ST_PAUSE:
-            self.__wait_vm_ready()
+            self.__wait_vm_ready(pin_threads=pin_threads)
 
             self.__wait_vmnet_ready()
 
@@ -1445,7 +1450,7 @@ class QEMUKvm(VirtBase):
 
         return logged_in
 
-    def __wait_vm_ready(self):
+    def __wait_vm_ready(self, pin_threads=True):
         logged_in = self.__ping_vm()
         if not logged_in:
             if not self.restarted:
@@ -1454,7 +1459,7 @@ class QEMUKvm(VirtBase):
                 self.vm_status = ST_NOTSTART
                 self._stop_vm()
                 self.restarted = True
-                self._start_vm()
+                self._start_vm(pin_threads=pin_threads)
             else:
                 raise StartVMFailedException(
                     "Not response in %d seconds!!!" % self.START_TIMEOUT
@@ -2005,12 +2010,11 @@ class QEMUKvm(VirtBase):
         """
         Pin thread to assigned cores
         """
-        thread_reg = r"CPU #(\d+): .* thread_id=(\d+)"
+        thread_reg = r"CPU #\d+: thread_id=(\d+)"
         output = self.__monitor_session("info", "cpus")
-        thread_cores = re.findall(thread_reg, output)
-        cores_map = list(zip(thread_cores, lcores))
-        for thread_info, core_id in cores_map:
-            cpu_id, thread_id = thread_info
+        threads = re.findall(thread_reg, output)
+        map = list(zip(lcores, threads))
+        for lcore, thread in map:
             self.host_session.send_expect(
-                "taskset -pc %d %s" % (core_id, thread_id), "#"
+                "taskset -pc %s %s" % (lcore, thread), "#"
             )
-- 
2.25.1


                 reply	other threads:[~2022-12-02  4:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221202043337.1179691-1-weix.ling@intel.com \
    --to=weix.ling@intel.com \
    --cc=dts@dpdk.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;
as well as URLs for NNTP newsgroup(s).