From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC2C6A0543; Fri, 2 Dec 2022 05:48:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B452E42BD9; Fri, 2 Dec 2022 05:48:44 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id C618340687 for ; Fri, 2 Dec 2022 05:48:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669956523; x=1701492523; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gBlwF4KDoUvj5KBKHPNjn0UvDVIcsApFob9HevnpEpQ=; b=mnlA3gemjx+PoFfvFoJrU5EmlUVZont2KSZmqukYR7WuB5Wh9kZKwYta rObl5JfU6XHS4q324cGBwMYW0gkIWx/EC/AnCEB/zXs5EySrUQvEaETrD fBtECTeiIOdrqpzoYI3wGPH+FlkiA/lVRRVf9CAXTTdwf/DZdNlv/rDRM jrUbtuOckfX001+yNWEV8ljGn2gJvK32UBgHtCy1fQs8iYFAnjxINVJZw MO+hYfD80rj5EWf+sfKdxuF08/YRCOc9k9vXuajma2iy6v6Pu8HPoDVk+ +ndvbPwM60NKLfd5TJsJZRaCq2YNVlhc0cWWCAHs1iZnFtVczr42c3PyE Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="296223827" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="296223827" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 20:48:41 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="675704497" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="675704497" Received: from unknown (HELO localhost.localdomain) ([10.239.252.222]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 20:48:35 -0800 From: Wei Ling To: dts@dpdk.org Cc: Wei Ling Subject: [dts][PATCH V2 1/2] framework/qemu_kvm: support pin VM's thread to vhost CPU lcore Date: Fri, 2 Dec 2022 12:42:43 +0800 Message-Id: <20221202044243.1180172-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org 1)Support pin VM's thread to vhost CPU lcore. 2)Fix add_vm_daemon issue. Signed-off-by: Wei Ling --- framework/qemu_kvm.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index 20aa8008..690bc808 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -1241,7 +1241,7 @@ class QEMUKvm(VirtBase): By default VM will start with the daemonize status. Not support starting it on the stdin now. """ - if "daemon" in list(options.keys()) and options["enable"] == "no": + if "enable" in list(options.keys()) and options["enable"] == "no": pass else: daemon_boot_line = "-daemonize" @@ -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,9 @@ 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 - self.host_session.send_expect( - "taskset -pc %d %s" % (core_id, thread_id), "#" - ) + threads = re.findall(thread_reg, output) + map = list(zip(lcores, threads)) + for lcore, thread in map: + self.host_session.send_expect("taskset -pc %s %s" % (lcore, thread), "#") -- 2.25.1