All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] netdev: stats on multiqueue possible bug
Date: Sun, 20 Sep 2009 09:24:08 +0200	[thread overview]
Message-ID: <4AB5D898.4080804@gmail.com> (raw)
In-Reply-To: <20090919222608.5fdf80b8@nehalam>

Stephen Hemminger a écrit :
> Dave, I think you were trying to optimize something here that
> doesn't need optimization.
> 
> If transmit stats (all) wrap to zero, then the stats would not
> be set correctly. Move local variable into loop as well.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> --- a/net/core/dev.c	2009-09-19 15:19:13.902495560 -0700
> +++ b/net/core/dev.c	2009-09-19 15:48:21.126458728 -0700
> @@ -5079,19 +5079,19 @@ const struct net_device_stats *dev_get_s
>  		unsigned long tx_bytes = 0, tx_packets = 0, tx_dropped = 0;
>  		struct net_device_stats *stats = &dev->stats;
>  		unsigned int i;
> -		struct netdev_queue *txq;
>  
>  		for (i = 0; i < dev->num_tx_queues; i++) {
> -			txq = netdev_get_tx_queue(dev, i);
> +			const struct netdev_queue *txq
> +				 = netdev_get_tx_queue(dev, i);
>  			tx_bytes   += txq->tx_bytes;
>  			tx_packets += txq->tx_packets;
>  			tx_dropped += txq->tx_dropped;
>  		}
> -		if (tx_bytes || tx_packets || tx_dropped) {
> -			stats->tx_bytes   = tx_bytes;
> -			stats->tx_packets = tx_packets;
> -			stats->tx_dropped = tx_dropped;
> -		}
> +
> +		stats->tx_bytes   = tx_bytes;
> +		stats->tx_packets = tx_packets;
> +		stats->tx_dropped = tx_dropped;
> +
>  		return stats;
>  	}
>  }

Most devices dont update txq->tx_bytes/tx_packets/tx_dropped yet, but
still update their device->stats

Your patch makes these devices clearing their stats.

In the case all stats wrap to zero, we'll give old values. If you think this is 
a bug, you should find another way to fix it :)

      reply	other threads:[~2009-09-20  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-20  5:26 [PATCH] netdev: stats on multiqueue possible bug Stephen Hemminger
2009-09-20  7:24 ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AB5D898.4080804@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.