From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3D1743B5 for ; Mon, 21 Sep 2015 09:34:59 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 21 Sep 2015 00:34:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,566,1437462000"; d="scan'208";a="648902573" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 21 Sep 2015 00:34:57 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t8L7YsPI028078; Mon, 21 Sep 2015 15:34:54 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t8L7YqpM004667; Mon, 21 Sep 2015 15:34:54 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t8L7Yque004663; Mon, 21 Sep 2015 15:34:52 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 21 Sep 2015 15:34:49 +0800 Message-Id: <1442820890-4631-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH 1/2] Optimize virtual dut module for abstract cpu topo X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 07:35:00 -0000 From: Marvin Liu In virtual machine, there's no concept of numa. When run performance case, when request cores according to socket will be error. Add new parameter "cpu_topo" in configuration file. With this parameter enabled, will generate core mapping with socket and hyperthread awareness. Add update virtual machine port infor function. When port is pass-through from host, update numa id with host device numa. Signed-off-by: Marvin Liu diff --git a/framework/virt_dut.py b/framework/virt_dut.py index 9404be6..529a2b1 100644 --- a/framework/virt_dut.py +++ b/framework/virt_dut.py @@ -54,9 +54,10 @@ class VirtDut(DPDKdut): or CRBBareMetal. """ - def __init__(self, hyper, crb, serializer, virttype, vm_name, suite): + def __init__(self, hyper, crb, serializer, virttype, vm_name, suite, cpu_topo): self.vm_name = vm_name self.hyper = hyper + self.cpu_topo = cpu_topo super(Dut, self).__init__(crb, serializer) self.vm_ip = self.get_ip_address() self.NAME = 'virtdut' + LOG_NAME_SEP + '%s' % self.vm_ip @@ -167,6 +168,10 @@ class VirtDut(DPDKdut): # scan ports before restore interface self.scan_ports() + + # update with real numa id + self.update_ports() + # restore dut ports to kernel if self.virttype != 'XEN': self.restore_interfaces() @@ -202,6 +207,38 @@ class VirtDut(DPDKdut): cpuinfo = self.send_expect("grep --color=never \"processor\"" " /proc/cpuinfo", "#", alt_session=False) cpuinfo = cpuinfo.split('\r\n') + if self.cpu_topo != '': + topo_reg = r"(\d)S/(\d)C/(\d)T" + m = re.match(topo_reg, self.cpu_topo) + if m: + socks = int(m.group(1)) + cores = int(m.group(2)) + threads = int(m.group(3)) + total = socks * cores * threads + cores_persock = cores * threads + total_phycores = socks * cores + # cores should match cpu_topo + if total != len(cpuinfo): + print dts.RED("Core number not matched!!!") + else: + for core in range(total): + thread = core / total_phycores + phy_core = core % total_phycores + # if this core is hyper core + if thread: + idx = core % total_phycores + socket = idx / cores + else: + socket = core / cores + + # tricky here, socket must be string + self.cores.append({'thread': core, + 'socket': str(socket), + 'core': phy_core}) + self.number_of_cores = len(self.cores) + return + + # default core map for line in cpuinfo: m = re.search("processor\t: (\d+)", line) if m: @@ -268,6 +305,26 @@ class VirtDut(DPDKdut): self, 'scan_ports_uncached_%s' % self.get_os_type()) return scan_ports_uncached() + def update_ports(self): + """ + Update ports information, according to host pci + """ + for port in self.ports_info: + vmpci = port['pci'] + for pci_map in self.hyper.pci_maps: + # search pci mapping strucutre + if vmpci == pci_map['guestpci']: + hostpci = pci_map['hostpci'] + # search host port info structure + for hostport in self.host_dut.ports_info: + # update port numa + if hostpci == hostport['pci'] or \ + hostpci in hostport['sriov_vfs_pci']: + port['numa'] = hostport['numa'] + port['port'].socket = hostport['numa'] + break + break + def map_available_ports(self): """ Load or generate network connection mapping list. -- 1.9.3