Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Sathya Perla <sathya.perla@emulex.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next-2.6 1/3] be2net: fix netdev_stats_update
Date: Fri, 24 Jun 2011 12:32:00 +0200	[thread overview]
Message-ID: <1308911520.2228.1.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> (raw)
In-Reply-To: <913f4373-e01f-4aa9-b8c7-d041d70f0945@exht1.ad.emulex.com>

Le vendredi 24 juin 2011 à 13:43 +0530, Sathya Perla a écrit :
> netdev_stats_update() resets netdev->stats and then accumulates stats from
> various rings. This is wrong as stats readers can sometimes catch zero values.
> Use temporary variables instead for accumulating per-ring values.
> 
> Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
> ---
>  drivers/net/benet/be_main.c |   29 +++++++++++++++++------------
>  1 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
> index c4f564c..5ca06b0 100644
> --- a/drivers/net/benet/be_main.c
> +++ b/drivers/net/benet/be_main.c
> @@ -428,33 +428,38 @@ void netdev_stats_update(struct be_adapter *adapter)
>  	struct net_device_stats *dev_stats = &adapter->netdev->stats;
>  	struct be_rx_obj *rxo;
>  	struct be_tx_obj *txo;
> +	unsigned long pkts = 0, bytes = 0, mcast = 0, drops = 0;
>  	int i;
>  
> -	memset(dev_stats, 0, sizeof(*dev_stats));
>  	for_all_rx_queues(adapter, rxo, i) {
> -		dev_stats->rx_packets += rx_stats(rxo)->rx_pkts;
> -		dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes;
> -		dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts;
> +		pkts += rx_stats(rxo)->rx_pkts;
> +		bytes += rx_stats(rxo)->rx_bytes;
> +		mcast += rx_stats(rxo)->rx_mcast_pkts;
>  		/*  no space in linux buffers: best possible approximation */
>  		if (adapter->generation == BE_GEN3) {
>  			if (!(lancer_chip(adapter))) {
> -				struct be_erx_stats_v1 *erx_stats =
> +				struct be_erx_stats_v1 *erx =
>  					be_erx_stats_from_cmd(adapter);
> -				dev_stats->rx_dropped +=
> -				erx_stats->rx_drops_no_fragments[rxo->q.id];
> +				drops += erx->rx_drops_no_fragments[rxo->q.id];
>  			}
>  		} else {
> -			struct be_erx_stats_v0 *erx_stats =
> +			struct be_erx_stats_v0 *erx =
>  					be_erx_stats_from_cmd(adapter);
> -			dev_stats->rx_dropped +=
> -				erx_stats->rx_drops_no_fragments[rxo->q.id];
> +			drops += erx->rx_drops_no_fragments[rxo->q.id];
>  		}
>  	}
> +	dev_stats->rx_packets = pkts;
> +	dev_stats->rx_bytes = bytes;
> +	dev_stats->multicast = mcast;
> +	dev_stats->rx_dropped = drops;
>  
> +	pkts = bytes = 0;
>  	for_all_tx_queues(adapter, txo, i) {
> -		dev_stats->tx_packets += tx_stats(txo)->be_tx_pkts;
> -		dev_stats->tx_bytes += tx_stats(txo)->be_tx_bytes;
> +		pkts += tx_stats(txo)->be_tx_pkts;
> +		bytes += tx_stats(txo)->be_tx_bytes;
>  	}
> +	dev_stats->tx_packets = pkts;
> +	dev_stats->tx_bytes = bytes;
>  
>  	/* bad pkts received */
>  	dev_stats->rx_errors = drvs->rx_crc_errors +



Hmm, isnt it a patch I provided 10 days ago ?

I find very strange so few people are able to properly attribute work
today...





  reply	other threads:[~2011-06-24  8:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-24  8:13 [PATCH net-next-2.6 1/3] be2net: fix netdev_stats_update Sathya Perla
2011-06-24 10:32 ` Eric Dumazet [this message]
2011-06-24  8:53   ` Sathya.Perla
2011-06-24 19:59   ` David Miller
2011-06-27  5:19     ` Sathya.Perla
2011-06-27  6:05       ` Eric Dumazet
2011-06-27  6:11       ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2011-06-27  6:40 Sathya Perla
2011-06-27  6:56 ` Eric Dumazet
2011-06-27  7:07   ` David Miller
2011-06-27 16:43 ` Stephen Hemminger
2011-06-27 17:20   ` Eric Dumazet
2011-06-27 18:43     ` Stephen Hemminger

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=1308911520.2228.1.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sathya.perla@emulex.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox