From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amos Kong Subject: [RFC PATCH 3/4] netperf: pin guest vcpus/memory/vhost thread to numa node Date: Fri, 23 Dec 2011 18:28:44 +0800 Message-ID: <20111223102844.29662.65380.stgit@dhcp-8-167.nay.redhat.com> References: <20111223102308.29662.59520.stgit@dhcp-8-167.nay.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: lmr@redhat.com, wquan@redhat.com, kvm@vger.kernel.org, jasowang@redhat.com, rhod@redhat.com, autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:53288 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753906Ab1LWK3F (ORCPT ); Fri, 23 Dec 2011 05:29:05 -0500 In-Reply-To: <20111223102308.29662.59520.stgit@dhcp-8-167.nay.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Dynamically checking hardware and pin guest cpu threads and guest memory to last numa node Signed-off-by: Amos Kong --- client/virt/tests/netperf.py | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/client/virt/tests/netperf.py b/client/virt/tests/netperf.py index 9c766bf..d4153fc 100644 --- a/client/virt/tests/netperf.py +++ b/client/virt/tests/netperf.py @@ -25,6 +25,20 @@ def run_netperf(test, params, env): server_ctl = vm.get_address(1) session.close() + logging.debug(commands.getoutput("numactl --hardware")) + logging.debug(commands.getoutput("numactl --show")) + # pin guest vcpus/memory/vhost threads to last numa node of host by default + numa_node = int(params.get('numa_node', -1)) + p = virt_utils.NumaNode(numa_node) + node_num = int(p.get_node_num()) + 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): + p.pin_cpu(i) + if "vm2" in params["vms"]: vm2 = env.get_vm("vm2") vm2.verify_alive() @@ -198,7 +212,10 @@ def launch_client(sessions, server, server_ctl, host, client, l, nf_args): return [nrx, ntx, nrxb, ntxb, nre, nrx_intr, ntx_intr, io_exit, irq_inj] def netperf_thread(i): - cmd = "%s -H %s -l %s %s" % (client_path, server, l, nf_args) + output = ssh_cmd(client, "numactl --hardware") + n = int(re.findall("available: (\d+) nodes", output)[0]) - 1 + cmd = "numactl --cpunodebind=%s --membind=%s %s -H %s -l %s %s" % \ + (n, n, client_path, server, l, nf_args) output = ssh_cmd(client, cmd) f = file("/tmp/netperf.%s.%s.nf" % (pid, i), "w") f.write(output)