From: "Michael S. Tsirkin" <mst@redhat.com>
To: Shirley Ma <mashirle@us.ibm.com>
Cc: Sridhar Samudrala <sri@us.ibm.com>, Shirley Ma <xma@us.ibm.com>,
David Stevens <dlstevens@us.ibm.com>,
kvm@vger.kernel.org, sri@linux.vnet.ibm.com,
mashirle@linux.vnet.ibm.com
Subject: Re: vhost-net patches
Date: Wed, 28 Oct 2009 17:39:00 +0200 [thread overview]
Message-ID: <20091028153859.GA28926@redhat.com> (raw)
In-Reply-To: <1256661378.6745.2.camel@localhost.localdomain>
On Tue, Oct 27, 2009 at 09:36:18AM -0700, Shirley Ma wrote:
> Hello Michael,
>
> On Tue, 2009-10-27 at 17:27 +0200, Michael S. Tsirkin wrote:
> > Possibly GFP_ATOMIC allocations in vring_add_indirect are failing?
> > Is there a chance you are tight on guest memory for some reason?
> > with vhost, virtio does currently consume a bit more memory than
> > with userspace backend.
>
> I did see memory leak on host every time after exiting guest. I don't
> know where. Do you see it?
>
> Anyway after I reboot host and restart guest with large memory
> allocation, I do see performance improves to 3xxxMb/s, and occasionally
> reaches 40xxMb/s. But "queue full" still exists, I can avoid the problem
> by increasing send queue size from qemu.
Here's another hack to try. It will break raw sockets,
but just as a test:
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index a140dad..e830b30 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -106,22 +106,41 @@ static void handle_tx(struct vhost_net *net)
.msg_flags = MSG_DONTWAIT,
};
size_t len, total_len = 0;
- int err;
+ int err, wmem;
size_t hdr_size;
struct socket *sock = rcu_dereference(vq->private_data);
- if (!sock || !sock_writeable(sock->sk))
+ if (!sock)
+ return;
+
+ wmem = atomic_read(&sock->sk->sk_wmem_alloc);
+ if (wmem >= sock->sk->sk_sndbuf)
return;
use_mm(net->dev.mm);
mutex_lock(&vq->mutex);
- tx_poll_stop(net);
+ vhost_no_notify(vq);
+
+ if (wmem >= sock->sk->sk_sndbuf * 3 / 4) {
+ //tx_poll_start(net);
+ } else {
+ //tx_poll_stop(net);
+ }
hdr_size = vq->hdr_size;
for (;;) {
head = vhost_get_vq_desc(&net->dev, vq, vq->iov, &out, &in);
/* Nothing new? Wait for eventfd to tell us they refilled. */
- if (head == vq->num)
+ if (head == vq->num) {
+ wmem = atomic_read(&sock->sk->sk_wmem_alloc);
+ if (wmem >= sock->sk->sk_sndbuf * 3 / 4) {
+ set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
+ break;
+ }
+ if (vhost_notify(vq)) {
+ continue;
+ }
break;
+ }
if (in) {
vq_err(vq, "Unexpected descriptor format for TX: "
"out %d, int %d\n", out, in);
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 30708c6..67bfc08 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -775,7 +775,7 @@ void vhost_no_notify(struct vhost_virtqueue *vq)
int vhost_init(void)
{
- vhost_workqueue = create_workqueue("vhost");
+ vhost_workqueue = create_singlethread_workqueue("vhost");
if (!vhost_workqueue)
return -ENOMEM;
return 0;
next prev parent reply other threads:[~2009-10-28 15:41 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1255721369.10322.38.camel@w-sridhar.beaverton.ibm.com>
[not found] ` <20091018105356.GA8374@redhat.com>
[not found] ` <20091018173202.GA32441@redhat.com>
2009-10-19 22:56 ` vhost-net patches Sridhar Samudrala
2009-10-20 10:24 ` Michael S. Tsirkin
[not found] ` <OFE487449E.75D4E72D-ON87257654.007E61BF-88257654.007F1CCC@us.ibm.com>
2009-10-20 11:34 ` Michael S. Tsirkin
[not found] ` <OF491C5580.D14A9827-ON87257655.005E2B42-88257655.005EBFDD@us.ibm.com>
2009-10-20 17:18 ` Michael S. Tsirkin
[not found] ` <OF519C21FE.3A50884E-ON87257655.005FB73B-88257655.005FEA00@us.ibm.com>
2009-10-20 17:33 ` Michael S. Tsirkin
[not found] ` <OFAA36418A.2A0716E0-ON87257656.006D1231-88257656.006DD91D@us.ibm.com>
2009-10-21 20:19 ` Michael S. Tsirkin
[not found] ` <OF2487602C.0F4CA77B-ON87257656.00834AC0-88257656.0083C68B@us.ibm.com>
2009-10-22 9:24 ` Michael S. Tsirkin
2009-10-22 10:56 ` Michael S. Tsirkin
2009-10-22 12:34 ` Michael S. Tsirkin
2009-10-22 13:13 ` Michael S. Tsirkin
2009-10-22 17:23 ` Shirley Ma
2009-10-22 17:32 ` Shirley Ma
2009-10-22 17:36 ` Michael S. Tsirkin
2009-10-22 17:44 ` Shirley Ma
2009-10-22 17:47 ` Michael S. Tsirkin
2009-10-22 17:56 ` Shirley Ma
2009-10-22 18:13 ` Shirley Ma
2009-10-22 17:43 ` Michael S. Tsirkin
2009-10-22 18:00 ` Sridhar Samudrala
2009-10-23 7:12 ` Michael S. Tsirkin
2009-10-23 11:04 ` Michael S. Tsirkin
2009-10-23 15:02 ` Shirley Ma
2009-10-23 15:12 ` Shirley Ma
2009-10-23 16:23 ` Shirley Ma
2009-10-25 10:52 ` Michael S. Tsirkin
2009-10-25 17:05 ` Michael S. Tsirkin
2009-10-26 9:27 ` Michael S. Tsirkin
2009-10-26 21:35 ` Shirley Ma
2009-10-26 20:05 ` Michael S. Tsirkin
2009-10-26 21:34 ` Shirley Ma
2009-10-27 6:43 ` Michael S. Tsirkin
2009-10-27 14:46 ` Shirley Ma
2009-10-27 15:27 ` Michael S. Tsirkin
2009-10-27 16:36 ` Shirley Ma
2009-10-27 20:58 ` Michael S. Tsirkin
2009-10-28 15:55 ` Shirley Ma
2009-10-28 15:39 ` Michael S. Tsirkin [this message]
2009-10-28 16:45 ` Shirley Ma
2009-10-28 16:53 ` Michael S. Tsirkin
2009-10-28 18:12 ` Shirley Ma
2009-10-29 7:11 ` Shirley Ma
2009-11-02 19:46 ` Michael S. Tsirkin
2009-11-03 1:06 ` Xin, Xiaohui
2009-11-03 15:52 ` Shirley Ma
2009-10-28 20:55 ` Shirley Ma
2009-10-28 16:46 ` kvm memory leak (Was Re: vhost-net patches) Michael S. Tsirkin
2009-10-29 12:21 ` Avi Kivity
2009-10-29 12:50 ` Avi Kivity
2009-10-23 19:24 ` vhost-net patches Shirley Ma
2009-10-25 9:11 ` Michael S. Tsirkin
2009-10-26 21:37 ` Shirley Ma
2009-10-27 6:38 ` Michael S. Tsirkin
2009-10-27 14:48 ` Shirley Ma
2009-10-28 17:46 ` Arnd Bergmann
2009-10-28 18:13 ` Shirley Ma
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=20091028153859.GA28926@redhat.com \
--to=mst@redhat.com \
--cc=dlstevens@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mashirle@linux.vnet.ibm.com \
--cc=mashirle@us.ibm.com \
--cc=sri@linux.vnet.ibm.com \
--cc=sri@us.ibm.com \
--cc=xma@us.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.