Received: by 10.223.164.202 with SMTP id h10csp3989340wrb; Tue, 28 Nov 2017 22:11:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMatkxOABl57g9F5wlt6sGXtgKcHAKTtbDiPPQdYhqw70Qj5/swEdwBDoZtzS48piYBZ87XY X-Received: by 10.99.116.30 with SMTP id p30mr1737556pgc.303.1511935898645; Tue, 28 Nov 2017 22:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511935898; cv=none; d=google.com; s=arc-20160816; b=lHpQmqTmDXDOK0I0IYHTf6Dilgqqmew30eKXgNI6V3tW3VLWz5iTkdPtKj34rPOz23 JSp6rItIA1VKEShdKlk/16Q6VGkrW13CXPHD+k20NQbqOiVPvfyzEnmiwkc+IuZwJrBe V56TOkWejuEzQuAKaDkhYee/JHQL+zRUsf3l3JBNSLR8pwXSVg4H3AEbcJu2KWtUi3I2 ubUWiFklwNfE/RpxCMT5Pzx9SqPbi4I/4QbItpPdydpbYJX3kiK7kjc7jnNcbfbCI0IU qxgjFg94r7+7GS3EbQKZGtKX1NmG23pjW23NHnjisZXM2CHuNFJ4n9uRfLg6shvkvBlG L3Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=gopurV+wq7NvFsU7PA96iK0Uo29r/FhEqKCP+aHzsJc=; b=nx0nG5IXFIUVCuIqh9KXs6BLiXMi28v3eplHSC12GugQtcR6n9zYLihd20k0sjQhS7 dzD2i06Ys9L4rv4vt8I8pDaUEb0ES6sg2rrdDGpQqLuVE1qHv/o99ppn6Rodk8InQK4/ Q6kqkVA8V9510P48a0BJw8ktgyBY/ecMfzpAa91YEncQQ1anFCXkWTK5nC17Kps8uKDw Kd3o0qN5c/XW461JINkmw2QH1gU3o9b8cTANz1OoaxG1+6EWCJa4lSXjnkSw3Qic4IaE 7wj5a4Ghwmz//OJRuPY8oROVWS2yctErzGf4tRnDkfO5EluA+1Rpe53Atg2dnlFdHsAL Vzjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si753328pgp.117.2017.11.28.22.11.28; Tue, 28 Nov 2017 22:11:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751911AbdK2GKt (ORCPT + 71 others); Wed, 29 Nov 2017 01:10:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38532 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbdK2GKs (ORCPT ); Wed, 29 Nov 2017 01:10:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55C08C0587DE; Wed, 29 Nov 2017 06:10:48 +0000 (UTC) Received: from Wei-Dev (dhcp-15-231.nay.redhat.com [10.66.15.231]) by smtp.corp.redhat.com (Postfix) with SMTP id 4ADE2600D5; Wed, 29 Nov 2017 06:10:44 +0000 (UTC) Date: Wed, 29 Nov 2017 14:32:18 +0800 From: Wei Xu To: "Michael S. Tsirkin" Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jasowang@redhat.com, mjrosato@linux.vnet.ibm.com Subject: Re: [PATCH net,stable] vhost: fix skb leak in handle_rx() Message-ID: <20171129063218.772bbousd6mk6vkg@Wei-Dev> References: <1511889436-12876-1-git-send-email-wexu@redhat.com> <20171128195140-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171128195140-mutt-send-email-mst@kernel.org> User-Agent: NeoMutt/20170113-14-7f1397-dirty (1.7.2) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 29 Nov 2017 06:10:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 28, 2017 at 07:53:33PM +0200, Michael S. Tsirkin wrote: > On Tue, Nov 28, 2017 at 12:17:16PM -0500, wexu@redhat.com wrote: > > From: Wei Xu > > > > Matthew found a roughly 40% tcp throughput regression with commit > > c67df11f(vhost_net: try batch dequing from skb array) as discussed > > in the following thread: > > https://www.mail-archive.com/netdev@vger.kernel.org/msg187936.html > > > > Eventually we figured out that it was a skb leak in handle_rx() > > when sending packets to the VM. This usually happens when a guest > > can not drain out vq as fast as vhost fills in, afterwards it sets > > off the traffic jam and leaks skb(s) which occurs as no headcount > > to send on the vq from vhost side. > > > > This can be avoided by making sure we have got enough headcount > > before actually consuming a skb from the batched rx array while > > transmitting, which is simply done by deferring it a moment later > > in this patch. > > > > Signed-off-by: Wei Xu > > Given the amount of effort Matthew has put into this, > you definitely want > > Reported-by: Matthew Rosato > > here. > Absolutely we want that, sorry for missed you here, Matthew. It is more like you have figured out this issue independently all by yourself with a wide assortment of extremely quick tests(tools, throughput, slub leak, etc), and I am happy that I have the opportunity to do the paperwork on behalf of you.:) Thanks a lot Matthew. Wei > Let's give credit where credit is due. > > Thanks a lot Matthew! > > > --- > > drivers/vhost/net.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > > index 8d626d7..e76535e 100644 > > --- a/drivers/vhost/net.c > > +++ b/drivers/vhost/net.c > > @@ -778,8 +778,6 @@ static void handle_rx(struct vhost_net *net) > > /* On error, stop handling until the next kick. */ > > if (unlikely(headcount < 0)) > > goto out; > > - if (nvq->rx_array) > > - msg.msg_control = vhost_net_buf_consume(&nvq->rxq); > > /* On overrun, truncate and discard */ > > if (unlikely(headcount > UIO_MAXIOV)) { > > iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1); > > @@ -809,6 +807,8 @@ static void handle_rx(struct vhost_net *net) > > */ > > iov_iter_advance(&msg.msg_iter, vhost_hlen); > > } > > + if (nvq->rx_array) > > + msg.msg_control = vhost_net_buf_consume(&nvq->rxq); > > err = sock->ops->recvmsg(sock, &msg, > > sock_len, MSG_DONTWAIT | MSG_TRUNC); > > /* Userspace might have consumed the packet meanwhile: > > -- > > 1.8.3.1 From 1585378486663576836@xxx Wed Nov 29 05:52:24 +0000 2017 X-GM-THRID: 1585331132080725538 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread