kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qin Chuanyu <qinchuanyu@huawei.com>
To: <davem@davemloft.net>, "Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>
Cc: KVM list <kvm@vger.kernel.org>
Subject: [PATCH] vhost: make vhost_zerocopy_callback more efficient by poll_queue base on vhost status
Date: Tue, 25 Feb 2014 14:55:48 +0800	[thread overview]
Message-ID: <530C3E74.6030409@huawei.com> (raw)

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 <qinchuanyu@huawei.com>
---
  drivers/vhost/net.c |   10 +++++++++-
  1 files changed, 9 insertions(+), 1 deletions(-)

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);

  	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) {
-- 
1.7.3.1.msysgit.0



             reply	other threads:[~2014-02-25  6:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25  6:55 Qin Chuanyu [this message]
2014-02-25  7:38 ` [PATCH] vhost: make vhost_zerocopy_callback more efficient by poll_queue base on vhost status Jason Wang
2014-02-25  7:53   ` Qin Chuanyu
2014-02-25  8:13     ` Jason Wang
2014-02-25  8:56       ` Qin Chuanyu
2014-02-25  9:30         ` Jason Wang
  -- strict thread matches above, loose matches on Subject: below --
2014-02-26  3:59 Qin Chuanyu
2014-02-26  6:29 ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=530C3E74.6030409@huawei.com \
    --to=qinchuanyu@huawei.com \
    --cc=davem@davemloft.net \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).