Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp814752ybb; Thu, 28 Mar 2019 12:43:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzd+9yILmcOVhvGyYbiwNK9Z+k2Wb1DrCZ1yv3/ALwfwdQX9fiFQch1/w95ppgs64NOJERt X-Received: by 2002:a17:902:7e46:: with SMTP id a6mr45139224pln.150.1553802214924; Thu, 28 Mar 2019 12:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553802214; cv=none; d=google.com; s=arc-20160816; b=HNibjWwXSeUv4SxE3+eg6rD1GEmLIVSrUGed4J2gJ8YorwkSKJtL55IhF/iuZrRPJK Gyh0J69uXdvOOpZNjKVNNfnY+LvbjCQKtR1mXT+o5tNfoCXE/6X0yTFKtMvR+TWfGiY0 vVQWay8Bwr55LjJa+h/yfIFZgr7LClJIi8lQMzTTremWpTPhbMXh+coDbbyuBdMVLLZI rDTcP++Kj87w/iUDKgQfv7g3dHlNTNVRgH15/gi8I/ult4mviyFfxudp4XjMrfzqHiEh aM1jkMK8Bcxte0VxjKbr1Rsyi8GdZ9gN4enzsbrWrprnYyTbJvUfdSkM0uBcZdfSsDoY z6FQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=B9zRhz/6pORXy69BKITtRDAURXnhfzFXtRl0HikpUzw=; b=LzVq51AYMxnC5syB8ZAhM02LymFFHaau/rMYYbxVO7M08DmTh8XenUlZQH+H9jhktt O35mF56lX8oVq/1kpA15PfeBAFbUqdcsuZfvZZHH/v1HRE1HD/TDBHWSLru+VTLXCrhT vHl2F5icz++sJaJaTaaz6TmCw44XXyOq6o40BBOOzhulDtPT2wAUcHwoQtTMJru8dwQK tvrH6d2HqXZKEqxhFWCrm1C7LSdYkDh+0BfJuomlFjm+Jd/Lsi495kPDVPhTgBXYAm9i r2DglD2cxDDdxhdcnam1fgRuiPJlkn0ZtYEZMbR8v9uJ8KxgS81s2eb8UT5KpjV8FE+U 2o1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=DpU2RT5d; 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 x8si18157738pgx.484.2019.03.28.12.43.18; Thu, 28 Mar 2019 12:43:34 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=DpU2RT5d; 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 S1726696AbfC1TmM (ORCPT + 99 others); Thu, 28 Mar 2019 15:42:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45877 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfC1TmL (ORCPT ); Thu, 28 Mar 2019 15:42:11 -0400 Received: by mail-pf1-f194.google.com with SMTP id e24so10964644pfi.12 for ; Thu, 28 Mar 2019 12:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B9zRhz/6pORXy69BKITtRDAURXnhfzFXtRl0HikpUzw=; b=DpU2RT5drjPDlvsC025OXDz5YJSnmd1C3a4UhZvPMRPdSWRgqb7enEBL879X+6U1xt a5yjPnn10WLmdUpi7/95PfWGkHxhFZVVfQZlXuCwyKEkSnwVQ6zMfI0ML9fBA71yHHmU VK5RG4UzQcKfi13vXduGMXnwkNKaDR8MtK+3geA7Iej4b4n3xyZCDsmlzXq/o1tH6onn uK1P7F5zWuMn2Vp86Snfo/iA1c1vN7k4I4QRGfV87r210naKvXX5hC0ZLTFv5KslPMOw LNICYtVb9hOygKf2WzbQnHyQn/RDI9w+5CDEvF4NqYYNM9pBlbc9TLfSJHafu05VLZXu fCfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B9zRhz/6pORXy69BKITtRDAURXnhfzFXtRl0HikpUzw=; b=DJkc76dR3gLn8viObhfkzYBlxBm4zftGQcq9ZBKQRCRDkAVQdEQgsOBLDFUhO8k3vg Q+H/W5UiY0Fr9BBzmroNpfKyOYFrTR2A7i+sDcc+9XZhYmz7K8751qpIftcYbg+M8J6Z CTJ5iTJX6+JNrAZQmPACYfVeLHnR62338pI78ZG6U+qGW7+Juhbvm249rsXD0nYkE9g0 jjUXB0KdFfPdXpTTbweAVnWqtta+/Xx+f3nU1ZvxopUvXTLIKYQheqwQixaGqpIDyDK9 kf+tY2bsi90o12FONkK01JXQ+yHHkXJkXekClaxz4VrYb3lgessGzYvFX6shLE+NDYvB TCtQ== X-Gm-Message-State: APjAAAVbmzimAxufk2g1EXY3xL73vUTC1iysPav4BAuV8U8jsJmABJIM tAfvYoNfxNHVwI3CtRpKjM1Rig== X-Received: by 2002:a65:4343:: with SMTP id k3mr23249292pgq.384.1553802130694; Thu, 28 Mar 2019 12:42:10 -0700 (PDT) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 17sm41548640pgz.52.2019.03.28.12.42.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 12:42:10 -0700 (PDT) Date: Thu, 28 Mar 2019 12:42:05 -0700 From: Stephen Hemminger To: Haiyang Zhang Cc: Haiyang Zhang , "sashal@kernel.org" , "linux-hyperv@vger.kernel.org" , KY Srinivasan , Stephen Hemminger , "olaf@aepfle.de" , vkuznets , "davem@davemloft.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH hyperv-fixes] hv_netvsc: Fix unwanted wakeup after tx_disable Message-ID: <20190328124205.42f5f337@shemminger-XPS-13-9360> In-Reply-To: References: <20190328174845.4799-1-haiyangz@linuxonhyperv.com> <20190328113823.3c9b3599@shemminger-XPS-13-9360> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Mar 2019 19:00:18 +0000 Haiyang Zhang wrote: > > -----Original Message----- > > From: Stephen Hemminger > > Sent: Thursday, March 28, 2019 2:38 PM > > To: Haiyang Zhang > > Cc: sashal@kernel.org; linux-hyperv@vger.kernel.org; Haiyang Zhang > > ; KY Srinivasan ; Stephen > > Hemminger ; olaf@aepfle.de; vkuznets > > ; davem@davemloft.net; netdev@vger.kernel.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH hyperv-fixes] hv_netvsc: Fix unwanted wakeup after > > tx_disable > > > > On Thu, 28 Mar 2019 17:48:45 +0000 > > Haiyang Zhang wrote: > > > > > +static inline void netvsc_tx_enable(struct netvsc_device *nvscdev, > > > + struct net_device *ndev) > > > +{ > > > + nvscdev->tx_disable = false; > > > + mb(); /* ensure queue wake up mechanism is on */ > > > + > > > + netif_tx_wake_all_queues(ndev); > > > +} > > > > You don't need a full mb(). virt_wmb() should be sufficient. > > I will make this change. > > > Could I suggest an alternative approach. > > You don't need to introduce a local tx_disable flag, the only place where a > > wakeup could cause problems is after a send_completion was processed > > during detach state. > > > > Instead, just avoid wakeup in that place. > > In netvsc_detach(), after netif_tx_disable(), we call netvsc_wait_until_empty(nvdev); > TX patch should not be waken up again while waiting for in/out ring to becomes empty. > > In my tests before this patch, there are wakeup happens before netif_device_detach(), > so netif_device_present(ndev) is still true at that time. > > In other places, like netvsc_close(), link_change(), we also don't want wakeup after tx_disable. > > Thanks. > - Haiyang > > > > > --- a/drivers/net/hyperv/netvsc.c > > +++ b/drivers/net/hyperv/netvsc.c > > @@ -720,6 +720,7 @@ static void netvsc_send_tx_complete(struct > > net_device *ndev, > > struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); > > > > if (netif_tx_queue_stopped(txq) && > > + netif_device_present(ndev) && > > (hv_get_avail_to_write_percent(&channel->outbound) > > > RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) { > > netif_tx_wake_queue(txq); Then what about doing netif_detach earlier in netvsc_detach. The state management is already (too) complex in netvsc and adding another boolean flag just makes it harder to understand.