From patchwork Tue Feb 25 06:55:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinchuanyu X-Patchwork-Id: 3713121 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B0868BF13A for ; Tue, 25 Feb 2014 06:56:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCBBC201B4 for ; Tue, 25 Feb 2014 06:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7E6E20165 for ; Tue, 25 Feb 2014 06:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751953AbaBYG4Y (ORCPT ); Tue, 25 Feb 2014 01:56:24 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:1188 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbaBYG4W (ORCPT ); Tue, 25 Feb 2014 01:56:22 -0500 Received: from 172.24.2.119 (EHLO szxeml213-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ALB28175; Tue, 25 Feb 2014 14:55:59 +0800 (CST) Received: from SZXEML417-HUB.china.huawei.com (10.82.67.156) by szxeml213-edg.china.huawei.com (172.24.2.30) with Microsoft SMTP Server (TLS) id 14.3.158.1; Tue, 25 Feb 2014 14:55:57 +0800 Received: from [127.0.0.1] (10.177.21.101) by szxeml417-hub.china.huawei.com (10.82.67.156) with Microsoft SMTP Server id 14.3.158.1; Tue, 25 Feb 2014 14:55:58 +0800 Message-ID: <530C3E74.6030409@huawei.com> Date: Tue, 25 Feb 2014 14:55:48 +0800 From: Qin Chuanyu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: , "Michael S. Tsirkin" , Jason Wang CC: KVM list Subject: [PATCH] vhost: make vhost_zerocopy_callback more efficient by poll_queue base on vhost status X-Originating-IP: [10.177.21.101] X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP guest kick vhost base on vring flag status and get perfermance improved, vhost_zerocopy_callback could do this in the same way, as virtqueue_enable_cb need one more check after change the status of avail_ring flags, vhost also do the same thing after vhost_enable_notify test result list as below: guest and host: suse11sp3, netperf, intel 2.4GHz +-------+----------+---------+----------+---------+ | | old | new | +-------+----------+---------+----------+---------+ | UDP | Gbit/s | PPS | Gbit/s | PPS | | 256 | 0.74805 | 321309 | 0.77933 | 334743 | | 512 | 1.42 | 328475 | 1.44 | 333550 | | 1024 | 2.79 | 334426 | 2.81 | 336986 | | 1460 | 3.71 | 316215 | 4.02 | 342325 | +-------+----------+---------+----------+---------+ Signed-off-by: Chuanyu Qin --- drivers/vhost/net.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) rcu_read_unlock_bh(); @@ -386,6 +388,12 @@ static void handle_tx(struct vhost_net *net) vhost_disable_notify(&net->dev, vq); continue; } + /* there might skb been freed between last + * vhost_zerocopy_signal_used and vhost_enable_notify, + * so one more check is needed. + */ + if (zcopy) + vhost_zerocopy_signal_used(net, vq); break; } if (in) { diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index a0fa5de..9bc0a15 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -322,7 +322,9 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success) * (the value 16 here is more or less arbitrary, it's tuned to trigger * less than 10% of times). */ - if (cnt <= 1 || !(cnt % 16)) + smp_rmb(); + if ((!(vq->used_flags & VRING_USED_F_NO_NOTIFY)) + && (cnt <= 1 || !(cnt % 16))) vhost_poll_queue(&vq->poll);