lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1308606356.2701.199.camel@bwh-desktop>
Date:	Mon, 20 Jun 2011 22:45:56 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Stephen Hemminger <shemminger@...tta.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 2/5] niu: fix 64 bit statistics on 32 bit
 platform

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.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ