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: <20140101.225033.1351962333260167430.davem@davemloft.net>
Date:	Wed, 01 Jan 2014 22:50:33 -0500 (EST)
From:	David Miller <davem@...emloft.net>
To:	roy.qing.li@...il.com
Cc:	netdev@...r.kernel.org, edumazet@...gle.com
Subject: Re: [PATCH net-next] ipv6: fix the use of pcpu_tstats in ip6_tunnel

From: roy.qing.li@...il.com
Date: Thu,  2 Jan 2014 08:49:40 +0800

> Eric Dumazet <edumazet@...gle.com>

What is this?

> Signed-off-by: Li RongQing <roy.qing.li@...il.com>
 ...
>  {
> -	struct pcpu_tstats sum = { 0 };
> +	struct pcpu_tstats tmp, sum = { 0 };
>  	int i;
>  
> -	for_each_possible_cpu(i) {
> -		const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
> +	BUILD_BUG_ON(offsetof(typeof(tmp), syncp) !=
> +		     sizeof(tmp) - sizeof(tmp.syncp));
>  
> -		sum.rx_packets += tstats->rx_packets;
> -		sum.rx_bytes   += tstats->rx_bytes;
> -		sum.tx_packets += tstats->tx_packets;
> -		sum.tx_bytes   += tstats->tx_bytes;
> +	for_each_possible_cpu(i) {
> +		unsigned int start;
> +		const struct pcpu_tstats *stat = per_cpu_ptr(dev->tstats, i);
> +
> +		do {
> +			start = u64_stats_fetch_begin_bh(&stat->syncp);
> +			memcpy(&tmp, stat, sizeof(tmp) - sizeof(stat->syncp));
> +		} while (u64_stats_fetch_retry_bh(&stat->syncp, start));

It's entirely wasteful and non-canonical to use an on-stack copy for this,
just surround the entire set of statistic increments within the u64 stats
updata sequence.  Then you don't need the on-stack thing.

--
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