Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3006247ybi; Mon, 17 Jun 2019 14:31:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKqImgRQM3BAlxU9Nulo4QSohe+c7DEuTiwxw5wzCc/7x2iwzrN04mTD+hvVd5+lEjpTmm X-Received: by 2002:aa7:84d1:: with SMTP id x17mr92576312pfn.188.1560807105358; Mon, 17 Jun 2019 14:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807105; cv=none; d=google.com; s=arc-20160816; b=CJ8SxrFEKTI8RCmjlLqcDe+naCsGwwAIP0cbNJ8xOCpePu7EbWFiFW84sJUobym9nI uqwVt/X5KIZb2dn3tYWTQwFwR15eHxYazp2cFxXO+diAOD2tTmEtaFLw4+vA91DdSqjO hQOx5CUStU9ItpiJNpHuotn+NoQJPP0VaCZ1OeoTTZbGUVhykzDyAMLrxV0Jsfyzv1XR STJxX2YBKzIVQptiLuYjeZvU6R9ovLCBg/oJXsEESMJw4ML6ODgD86s5+dq9M4VSHVn/ jAa7PDgGgJDCuUOo4APZSUDC/YLBE704aCO+/x90y7JxIY1dUMryAaGPSCW2gvUgVlRb Gkvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Km4TimG0RuOAEQikf+f6S7/QT2j6iyvhAGf9ARWOcbs=; b=ul1nBWZcVBXxCO7l3z8JEoSc6MhyCdRBftVNljn4eg7hSxTNZejqDPXuR6mDrgAoP6 8JJg8FMWhrJ9osaI4BZ6B+b/vNEDYyplcih6FRnsz75LklQff/+cwHWagstpXxY4hFyJ GIgjFwzjKERueqGd4h8nrOyEQ7O61N1Z7ENxOXDEX9pw5/NBc2qrAFYEJLFw3CvT+Z38 Z6f6Uv1DRuOEXur7Ki4qWoytVjW9FKE8N47+xG5t+xD8pCmiT3ni8PaTRzan/zAF4OMQ ZE+DoNCG0U51us8leNqw3bKivjJttg05TLuRTA83imYMz48jP7/A6YzXsvJ5rZpk1LGR B//w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cJSYzBz+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si303044pjq.56.2019.06.17.14.31.30; Mon, 17 Jun 2019 14:31:45 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=cJSYzBz+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730093AbfFQVbN (ORCPT + 99 others); Mon, 17 Jun 2019 17:31:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:56328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730129AbfFQV3J (ORCPT ); Mon, 17 Jun 2019 17:29:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CA39204FD; Mon, 17 Jun 2019 21:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806949; bh=eoircKri8yZq6TBBlqggoJktGga+3JD24JCOXyw7Q5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJSYzBz+F7zIYIT6azmVS+fz2gndgzvgsPudy8yurAfg6uKo3+JR8sZK8eR4PpAqQ 4M+7XeecaowjRuAyTMBg/n7ySjkgOzfnlhePu9JWQPw18zA0uaWq9f9ptSv69FDJsG TpPA0J/ytwkCg/3kYuADWJLTWPHMnAAH2Dd/Lw4s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Zweigle , Bernd Eckstein <3ernd.Eckstein@gmail.com>, "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 38/53] usbnet: ipheth: fix racing condition Date: Mon, 17 Jun 2019 23:10:21 +0200 Message-Id: <20190617210751.822790637@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210745.104187490@linuxfoundation.org> References: <20190617210745.104187490@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 94d250fae48e6f873d8362308f5c4d02cd1b1fd2 ] Fix a racing condition in ipheth.c that can lead to slow performance. Bug: In ipheth_tx(), netif_wake_queue() may be called on the callback ipheth_sndbulk_callback(), _before_ netif_stop_queue() is called. When this happens, the queue is stopped longer than it needs to be, thus reducing network performance. Fix: Move netif_stop_queue() in front of usb_submit_urb(). Now the order is always correct. In case, usb_submit_urb() fails, the queue is woken up again as callback will not fire. Testing: This racing condition is usually not noticeable, as it has to occur very frequently to slowdown the network. The callback from the USB is usually triggered slow enough, so the situation does not appear. However, on a Ubuntu Linux on VMWare Workstation, running on Windows 10, the we loose the race quite often and the following speedup can be noticed: Without this patch: Download: 4.10 Mbit/s, Upload: 4.01 Mbit/s With this patch: Download: 36.23 Mbit/s, Upload: 17.61 Mbit/s Signed-off-by: Oliver Zweigle Signed-off-by: Bernd Eckstein <3ernd.Eckstein@gmail.com> Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/ipheth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 3d8a70d3ea9b..3d71f1716390 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -437,17 +437,18 @@ static int ipheth_tx(struct sk_buff *skb, struct net_device *net) dev); dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + netif_stop_queue(net); retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); if (retval) { dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", __func__, retval); dev->net->stats.tx_errors++; dev_kfree_skb_any(skb); + netif_wake_queue(net); } else { dev->net->stats.tx_packets++; dev->net->stats.tx_bytes += skb->len; dev_consume_skb_any(skb); - netif_stop_queue(net); } return NETDEV_TX_OK; -- 2.20.1