Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2197346ybp; Sat, 12 Oct 2019 06:02:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFdskBNw5GhoI4e/99CbrWJI1JKoSiapXKklc5j0fAh8sTAFnLKOeBXDcqgrNBgs0daTBu X-Received: by 2002:aa7:d389:: with SMTP id x9mr18800823edq.33.1570885334193; Sat, 12 Oct 2019 06:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570885334; cv=none; d=google.com; s=arc-20160816; b=oWZeh2fDtvty1QuCTVIfqWU7JDvAX6rb3Cdb8LjYVtY6CQMlfQp5XCpUrHVnNzHCdJ U8HBQPWlNTkQfi3/vpMxwppIvTeiQN5tZzDK1xLmxdnoAUeaaOTZ5uys6lS+HPs1nKzK 3VDMqkVtTuUc+krEXhovq1q1M6KPgvE6xsewdhDnIQ2eTt50SsqYtaRDmeQ9/hkR3ov/ 2ypd1agdteitjIag2Rkbt6SgI+P+9J7LB4/JJa59OswUc2BBHx3o8/XpW/GqLyRWOVqB 2TwM5AP9H0xxTvXPCo8DgAWH6+7SQwGF3ikvxmD+2xGnuJda+c4YtkkZ6Eqj5joQDg4U VDmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+5Vm9VH+C6rhEWsX0fYWR+nCugsrZMdrW9HQZBYTQfo=; b=EZ+xdDtfuNyw1U7iO6003ctHivAX0atwRmpUc0sqUNDGZMz/z0ocF7NQyHlAn+wiGP 40Gsszpkbfvg40OpackSV9hG47OnkmjuhTLBUqPB23J3NmBObFVS271zk7+DTodq1yqh kgkzJdpea+bzeBt0mcJGppSwKRn9Nhyukb752Qeqf4yBzkPXNmCPDdpYxFSKzWly3VsX UZZAtFDwp3uYpVmDLCZkO4tvYQQBk4HOzeSy0NetI2ZKybKgjZ6zMz8a8N7RA5WeDWoB 2m0t5aSJe9zspfcHfE1qnsUFHNVOxuuYL5PAM+zMozH2ieNLZwF35UwDiyxI4/Oh4Tsw dWrA== 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 b9si7618118edj.0.2019.10.12.06.01.50; Sat, 12 Oct 2019 06:02:14 -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; 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 S1729091AbfJLNBg (ORCPT + 99 others); Sat, 12 Oct 2019 09:01:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55226 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbfJLNBg (ORCPT ); Sat, 12 Oct 2019 09:01:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B34AC05AA65; Sat, 12 Oct 2019 13:01:36 +0000 (UTC) Received: from [10.72.12.16] (ovpn-12-16.pek2.redhat.com [10.72.12.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD7911C945; Sat, 12 Oct 2019 13:01:30 +0000 (UTC) Subject: Re: [PATCH RFC net-next 2/2] drivers: net: virtio_net: Add tx_timeout function To: jcfaracco@gmail.com, netdev@vger.kernel.org Cc: mst@redhat.com, davem@davemloft.net, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, dnmendes76@gmail.com References: <20191006184515.23048-1-jcfaracco@gmail.com> <20191006184515.23048-3-jcfaracco@gmail.com> From: Jason Wang Message-ID: <6c7a48ee-b900-c77d-8d12-35fd242f2e6f@redhat.com> Date: Sat, 12 Oct 2019 21:01:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191006184515.23048-3-jcfaracco@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 12 Oct 2019 13:01:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/7 上午2:45, jcfaracco@gmail.com wrote: > From: Julio Faracco > > To enable dev_watchdog, virtio_net should have a tx_timeout defined > (.ndo_tx_timeout). This is only a skeleton to throw a warn message. It > notifies the event in some specific queue of device. This function > still counts tx_timeout statistic and consider this event as an error > (one error per queue), reporting it. > > Signed-off-by: Julio Faracco > Signed-off-by: Daiane Mendes > Cc: Jason Wang > --- > drivers/net/virtio_net.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 27f9b212c9f5..4b703b4b9441 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -2585,6 +2585,29 @@ static int virtnet_set_features(struct net_device *dev, > return 0; > } > > +static void virtnet_tx_timeout(struct net_device *dev) > +{ > + struct virtnet_info *vi = netdev_priv(dev); > + u32 i; > + > + /* find the stopped queue the same way dev_watchdog() does */ > + for (i = 0; i < vi->curr_queue_pairs; i++) { > + struct send_queue *sq = &vi->sq[i]; > + > + if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) > + continue; > + > + u64_stats_update_begin(&sq->stats.syncp); > + sq->stats.tx_timeouts++; > + u64_stats_update_end(&sq->stats.syncp); > + > + netdev_warn(dev, "TX timeout on send queue: %d, sq: %s, vq: %d, name: %s\n", > + i, sq->name, sq->vq->index, sq->vq->name); If this is just a warn for a specific queue, maybe it's better to do it in the dev_watchdog()? Or we may want more information like avail,used idx etc. And usually there will be a reset, any reason for not doing this? Thanks > + > + dev->stats.tx_errors++; > + } > +} > + > static const struct net_device_ops virtnet_netdev = { > .ndo_open = virtnet_open, > .ndo_stop = virtnet_close, > @@ -2600,6 +2623,7 @@ static const struct net_device_ops virtnet_netdev = { > .ndo_features_check = passthru_features_check, > .ndo_get_phys_port_name = virtnet_get_phys_port_name, > .ndo_set_features = virtnet_set_features, > + .ndo_tx_timeout = virtnet_tx_timeout, > }; > > static void virtnet_config_changed_work(struct work_struct *work) > @@ -3018,6 +3042,9 @@ static int virtnet_probe(struct virtio_device *vdev) > dev->netdev_ops = &virtnet_netdev; > dev->features = NETIF_F_HIGHDMA; > > + /* Set up dev_watchdog cycle. */ > + dev->watchdog_timeo = 5 * HZ; > + > dev->ethtool_ops = &virtnet_ethtool_ops; > SET_NETDEV_DEV(dev, &vdev->dev); >