From patchwork Fri Jun 7 14:05:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2687061 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 26539DFB78 for ; Fri, 7 Jun 2013 14:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754557Ab3FGOGT (ORCPT ); Fri, 7 Jun 2013 10:06:19 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:35395 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382Ab3FGOGS (ORCPT ); Fri, 7 Jun 2013 10:06:18 -0400 Received: by mail-qc0-f175.google.com with SMTP id k14so1705649qcv.34 for ; Fri, 07 Jun 2013 07:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Aoe7habQf8hoU/sauTKzyqDAUcznMhRgRmeHdx1oL9Y=; b=v8aZuvJ2fMBaJFXURp9wwjko+wDZkxDFfd49YKeZq1zMbZ0mEC5GnvoPg9uuand2vL 0he29ZrZllTq2LYM8iXxSNVnBGja61hhm8WWSBmef8c6kISZ2mCIXVzpCQGMsKtE8LNl u3K28He/PPcy1QRMWgwAQMwTbEK7sPNGE4iXmpzpNCERNoTBhYuqtFdpkQE2UOd4eYID 3QdkIooayzCEWEinddQ7KHWgihFOmGRnzukicf8c18pTLUZ4CGnb+m0O0NJjGvblubBO c0gS/AuPD4INc3c7tTb6XjpDyHvTZXS+y+o9vOmmmziYCu+z1LsMzdTAybnKLHfHTF4D Er+Q== X-Received: by 10.49.74.3 with SMTP id p3mr47146296qev.32.1370613977425; Fri, 07 Jun 2013 07:06:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.41.145 with HTTP; Fri, 7 Jun 2013 07:05:37 -0700 (PDT) In-Reply-To: <51B1E518.1070003@huawei.com> References: <51B1E518.1070003@huawei.com> From: Asias He Date: Fri, 7 Jun 2013 22:05:37 +0800 Message-ID: Subject: Re: [PATCH] vhost: wake up worker outside spin_lock To: Qin Chuanyu Cc: "Michael S. Tsirkin" , Jason Wang , KVM , netdev@vger.kernel.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, Jun 7, 2013 at 9:50 PM, Qin Chuanyu wrote: > the wake_up_process func is included by spin_lock/unlock in > vhost_work_queue, > but it could be done outside the spin_lock. > I have test it with kernel 3.0.27 and guest suse11-sp2 using iperf, > the num as below. > original modified > > thread_num tp(Gbps) vhost(%) | tp(Gbps) vhost(%) > 1 9.59 28.82 | 9.59 27.49 > 8 9.61 32.92 | 9.62 26.77 > 64 9.58 46.48 | 9.55 38.99 > 256 9.6 63.7 | 9.6 52.59 > > Signed-off-by: Chuanyu Qin > --- > drivers/vhost/vhost.c | 4 +++- > > 1 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 94dbd25..dcc7a17 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -146,9 +146,11 @@ static inline void vhost_work_queue(struct vhost_dev > *dev, > > if (list_empty(&work->node)) { > list_add_tail(&work->node, &dev->work_list); > work->queue_seq++; > + spin_unlock_irqrestore(&dev->work_lock, flags); > wake_up_process(dev->worker); > + } else { > + spin_unlock_irqrestore(&dev->work_lock, flags); > } > - spin_unlock_irqrestore(&dev->work_lock, flags); > > } Hmm, this looks more clearer to me. > > void vhost_poll_queue(struct vhost_poll *poll) > -- > 1.7.3.1.msysgit.0 > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- Asias -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -156,14 +156,17 @@ EXPORT_SYMBOL_GPL(vhost_poll_flush); void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) { unsigned long flags; + bool wakeup = false; spin_lock_irqsave(&dev->work_lock, flags); if (list_empty(&work->node)) { list_add_tail(&work->node, &dev->work_list); work->queue_seq++; - wake_up_process(dev->worker); + wakeup = true; } spin_unlock_irqrestore(&dev->work_lock, flags); + if (wakeup) + wake_up_process(dev->worker); }