netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/5] niu: fix 64 bit statistics on 32 bit platform
Date: Mon, 20 Jun 2011 22:45:56 +0100	[thread overview]
Message-ID: <1308606356.2701.199.camel@bwh-desktop> (raw)
In-Reply-To: <20110620203602.739916889@vyatta.com>

On Mon, 2011-06-20 at 13:35 -0700, Stephen Hemminger wrote:

> This resolves issues with NIU driver statistics wrapping on 32 bit SMP.
> Use stats_sync wrapper for bytes and packets, and change error counters
> to natural word size (unsigned long).
[...]
>  static void niu_get_tx_stats(struct niu *np,
>  			     struct rtnl_link_stats64 *stats)
>  {
> -	u64 pkts, errors, bytes;
>  	struct tx_ring_info *tx_rings;
>  	int i;
>  
> -	pkts = errors = bytes = 0;
> -
>  	tx_rings = ACCESS_ONCE(np->tx_rings);
>  	if (!tx_rings)
> -		goto no_rings;
> +		return;
>  
>  	for (i = 0; i < np->num_tx_rings; i++) {
>  		struct tx_ring_info *rp = &tx_rings[i];
> +		unsigned int start;
> +		u64 pkts, bytes;
>  
> -		pkts += rp->tx_packets;
> -		bytes += rp->tx_bytes;
> -		errors += rp->tx_errors;
> +		do {
> +			start = u64_stats_fetch_begin(&rp->syncp);
> +			pkts   = rp->tx_packets;
> +			bytes  = rp->tx_bytes;
> +		} while (u64_stats_fetch_retry(&rp->syncp, start));
> +
> +		stats->tx_packets += pkts;
> +		stats->tx_bytes   += bytes;
> +		stats->tx_errors  += rp->tx_errors;
>  	}
[...]

It looks like you also need to update release_tx_packet() where these
stats are written.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2011-06-20 21:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 20:35 [PATCH net-next 0/5] more statistics updates Stephen Hemminger
2011-06-20 20:35 ` [PATCH net-next 1/5] vxge: fix 64 bit access on 32 bit platforms Stephen Hemminger
2011-06-21 22:56   ` David Miller
2011-06-20 20:35 ` [PATCH net-next 2/5] niu: fix 64 bit statistics on 32 bit platform Stephen Hemminger
2011-06-20 21:45   ` Ben Hutchings [this message]
2011-06-20 21:52     ` Stephen Hemminger
2011-06-20 22:02       ` Eric Dumazet
2011-06-20 20:35 ` [PATCH net-next 3/5] netxen: make 64 bit stats safe " Stephen Hemminger
2011-06-20 21:50   ` Eric Dumazet
2011-06-20 21:52   ` Ben Hutchings
2011-06-20 22:18     ` Stephen Hemminger
2011-06-20 22:27       ` Ben Hutchings
2011-06-20 20:35 ` [PATCH net-next 4/5] xen: convert to 64 bit stats interface Stephen Hemminger
2011-06-21 14:05   ` [Xen-devel] " Ian Campbell
2011-06-21 15:29     ` Stephen Hemminger
2011-06-21 15:35     ` Stephen Hemminger
2011-06-21 15:38       ` Ian Campbell
2011-06-21 22:57         ` David Miller
2011-06-20 20:56 ` [PATCH net-next 0/5] more statistics updates David Miller
2011-06-20 21:12   ` [PATCH net-next 5/5] ifb: convert to 64 bit stats Stephen Hemminger
2011-06-20 21:23     ` Eric Dumazet
2011-06-20 21:27       ` Eric Dumazet
2011-06-20 21:38         ` Stephen Hemminger
2011-06-20 21:42           ` Eric Dumazet
2011-06-20 21:42         ` [PATCH net-next 5/5] ifb: convert to 64 bit stats (v3) Stephen Hemminger
2011-06-20 21:44           ` Eric Dumazet
2011-06-21  0:04             ` jamal
2011-06-21 22:55               ` David Miller

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=1308606356.2701.199.camel@bwh-desktop \
    --to=bhutchings@solarflare.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).