From patchwork Fri Jun 7 13:50:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinchuanyu X-Patchwork-Id: 2687051 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 05A54DFB78 for ; Fri, 7 Jun 2013 13:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753322Ab3FGNur (ORCPT ); Fri, 7 Jun 2013 09:50:47 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:22963 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382Ab3FGNuq (ORCPT ); Fri, 7 Jun 2013 09:50:46 -0400 Received: from 172.24.2.119 (EHLO szxeml213-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BDI98049; Fri, 07 Jun 2013 21:50:32 +0800 (CST) Received: from SZXEML450-HUB.china.huawei.com (10.82.67.193) by szxeml213-edg.china.huawei.com (172.24.2.30) with Microsoft SMTP Server (TLS) id 14.1.323.7; Fri, 7 Jun 2013 21:50:30 +0800 Received: from [127.0.0.1] (10.135.68.166) by szxeml450-hub.china.huawei.com (10.82.67.193) with Microsoft SMTP Server id 14.1.323.7; Fri, 7 Jun 2013 21:50:31 +0800 Message-ID: <51B1E518.1070003@huawei.com> Date: Fri, 7 Jun 2013 21:50:16 +0800 From: Qin Chuanyu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: , CC: , Subject: [PATCH] vhost: wake up worker outside spin_lock X-Originating-IP: [10.135.68.166] X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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(-) void vhost_poll_queue(struct vhost_poll *poll) 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); }