From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: Performance test result between per-vhost kthread disable and enable Date: Thu, 9 Dec 2010 15:31:09 +0200 Message-ID: <20101209133108.GB22460@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: tj@kernel.org, sri@us.ibm.com, Avi Kivity , kvm@vger.kernel.org To: lidong chen Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56063 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750747Ab0LINbr (ORCPT ); Thu, 9 Dec 2010 08:31:47 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Nov 23, 2010 at 10:13:43AM +0800, lidong chen wrote: > I test the performance between per-vhost kthread disable and enable. > > Test method: > Send the same traffic load between per-vhost kthread disable and > enable, and compare the cpu rate of host os. > I run five vm on kvm, each of them have five nic. > the vhost version which per-vhost kthread disable we used is rhel6 > beta 2(2.6.32.60). > the vhost version which per-vhost kthread enable we used is rhel6 (2.6.32-71). > > Test result: > with per-vhost kthread disable, the cpu rate of host os is 110%. > with per-vhost kthread enable, the cpu rate of host os is 130%. Does it help if we schedule out the thread once we've passed once over all vqs? Something like this: diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 1b0a20d..256e915 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -175,6 +175,7 @@ static int vhost_worker(void *data) struct vhost_dev *dev = data; struct vhost_work *work = NULL; unsigned uninitialized_var(seq); + int n = 0; use_mm(dev->mm); @@ -206,9 +207,11 @@ static int vhost_worker(void *data) if (work) { __set_current_state(TASK_RUNNING); work->fn(work); - } else - schedule(); - + if (likely(++n < dev->nvqs)) + continue; + } + schedule(); + n = 0; } unuse_mm(dev->mm); return 0;