From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 306DAC282CE for ; Wed, 22 May 2019 20:02:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 019F820863 for ; Wed, 22 May 2019 20:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558555376; bh=KpFcdmm4gIKg5OZzcPyu9/fqLfOfiTlvucJODDJESeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CZG6TSgydo/ZYpgkjLkR9jvet4N+dES7hYf/mBO/6gNqPhroBvx4WybJSrlbck79u mhyp3KJL6/+Sy2gSbuZiJ5UjHheY80bAdsqNG8zbQBnwMvg+sRP3hq6oY8l6YdpzfS 1V/QzMbHgotNahYoXD/xbRcCLFAi8wsei0EIvfdg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731039AbfEVUCs (ORCPT ); Wed, 22 May 2019 16:02:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730091AbfEVTVv (ORCPT ); Wed, 22 May 2019 15:21:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 327FE2173E; Wed, 22 May 2019 19:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558552911; bh=KpFcdmm4gIKg5OZzcPyu9/fqLfOfiTlvucJODDJESeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BqnXnlxNpghaaSZ4MNxRKvexUor8MiTBJds/bQCU38K94T8Rca+ggfV1M0lJpfTK/ A/7AOzzy5kudJUn4UhsuMlCzNj87nZeQH9obK++nF7iP6jRSGKWQdndxkFyCEPAM3m WCwh6C2kyZm58Uri3PxQqpesF+wP6dE9O4Xn6p/I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Haiyang Zhang , Stephan Klein , "David S . Miller" , Sasha Levin , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.1 024/375] hv_netvsc: fix race that may miss tx queue wakeup Date: Wed, 22 May 2019 15:15:24 -0400 Message-Id: <20190522192115.22666-24-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190522192115.22666-1-sashal@kernel.org> References: <20190522192115.22666-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-hyperv-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org From: Haiyang Zhang [ Upstream commit 93aa4792c3908eac87ddd368ee0fe0564148232b ] When the ring buffer is almost full due to RX completion messages, a TX packet may reach the "low watermark" and cause the queue stopped. If the TX completion arrives earlier than queue stopping, the wakeup may be missed. This patch moves the check for the last pending packet to cover both EAGAIN and success cases, so the queue will be reliably waked up when necessary. Reported-and-tested-by: Stephan Klein Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index e0dce373cdd9d..3d4a166a49d58 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -875,12 +875,6 @@ static inline int netvsc_send_pkt( } else if (ret == -EAGAIN) { netif_tx_stop_queue(txq); ndev_ctx->eth_stats.stop_queue++; - if (atomic_read(&nvchan->queue_sends) < 1 && - !net_device->tx_disable) { - netif_tx_wake_queue(txq); - ndev_ctx->eth_stats.wake_queue++; - ret = -ENOSPC; - } } else { netdev_err(ndev, "Unable to send packet pages %u len %u, ret %d\n", @@ -888,6 +882,15 @@ static inline int netvsc_send_pkt( ret); } + if (netif_tx_queue_stopped(txq) && + atomic_read(&nvchan->queue_sends) < 1 && + !net_device->tx_disable) { + netif_tx_wake_queue(txq); + ndev_ctx->eth_stats.wake_queue++; + if (ret == -EAGAIN) + ret = -ENOSPC; + } + return ret; } -- 2.20.1