Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Decotigny <david.decotigny@google.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Ian Campbell <ian.campbell@citrix.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	Ben Hutchings <bhutchings@solarflare.com>,
	Jiri Pirko <jpirko@redhat.com>, Joe Perches <joe@perches.com>,
	Szymon Janc <szymon@janc.net.pl>,
	Richard Jones <rick.jones2@hp.com>,
	Ayaz Abdulla <AAbdulla@nvidia.com>
Subject: Re: [PATCH net-next v6 7/9] forcedeth: implement ndo_get_stats64() API
Date: Thu, 17 Nov 2011 07:34:38 +0100	[thread overview]
Message-ID: <1321511678.3274.30.camel@edumazet-laptop> (raw)
In-Reply-To: <185a0f33c69ff07e8fe3482828b368371420bf47.1321481064.git.david.decotigny@google.com>

Le mercredi 16 novembre 2011 à 14:15 -0800, David Decotigny a écrit :
> This commit implements the ndo_get_stats64() API for forcedeth. Since
> hardware stats are being updated from different contexts (process and
> timer), this commit adds synchronization. For software stats, it
> relies on the u64_stats_sync.h API.
> 
> Tested:
>   - 16-way SMP x86_64 ->
>     RX bytes:7244556582 (7.2 GB)  TX bytes:181904254 (181.9 MB)
>   - pktgen + loopback: identical rx_bytes/tx_bytes and rx_packets/tx_packets
> 
> 
> 
> Signed-off-by: David Decotigny <david.decotigny@google.com>
> ---
>  drivers/net/ethernet/nvidia/forcedeth.c |  197 +++++++++++++++++++++++--------
>  1 files changed, 146 insertions(+), 51 deletions(-)
> 


> +static struct rtnl_link_stats64*
> +nv_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *storage)
> +	__acquires(&netdev_priv(dev)->hwstats_lock)
> +	__releases(&netdev_priv(dev)->hwstats_lock)
>  {
>  	struct fe_priv *np = netdev_priv(dev);
> +	unsigned int syncp_start;
> +
> +	/*
> +	 * Note: because HW stats are not always available and for
> +	 * consistency reasons, the following ifconfig stats are
> +	 * managed by software: rx_bytes, tx_bytes, rx_packets and
> +	 * tx_packets. The related hardware stats reported by ethtool
> +	 * should be equivalent to these ifconfig stats, with 4
> +	 * additional bytes per packet (Ethernet FCS CRC), except for
> +	 * tx_packets when TSO kicks in.
> +	 */
> +
> +	/* software stats */
> +	do {
> +		syncp_start = u64_stats_fetch_begin(&np->swstats_rx_syncp);
> +		storage->rx_packets       = np->stat_rx_packets;
> +		storage->rx_bytes         = np->stat_rx_bytes;
> +		storage->rx_missed_errors = np->stat_rx_missed_errors;
> +	} while (u64_stats_fetch_retry(&np->swstats_rx_syncp, syncp_start));
> +
> +	do {
> +		syncp_start = u64_stats_fetch_begin(&np->swstats_tx_syncp);
> +		storage->tx_packets = np->stat_tx_packets;
> +		storage->tx_bytes   = np->stat_tx_bytes;
> +		storage->tx_dropped = np->stat_tx_dropped;
> +	} while (u64_stats_fetch_retry(&np->swstats_tx_syncp, syncp_start));
>  

I have no idea why you think u64_stats_fetch_begin() is safe on 32bit
arch here.

Hint : On CONFIG_SMP=n build, only preemption is disabled in
u64_stats_fetch_begin()

So an interrupt could come and change your counters while you were
reading them.

Its very unlikely, but its possible.

You should use the _bh variants.

  reply	other threads:[~2011-11-17  6:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16 22:15 [PATCH net-next v6 0/9] net-sysfs+forcedeth: stats & debug enhancements David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 1/9] forcedeth: fix stats on hardware without extended stats support David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 2/9] net-sysfs: fixed minor sparse warning David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 3/9] kbuild: document RPS/XPS network Kconfig options David Decotigny
2011-11-16 23:12   ` Ben Hutchings
2011-11-17  1:54     ` David Decotigny
2011-11-17  2:54       ` Ben Hutchings
2011-11-17  2:59         ` David Miller
2011-11-17  3:19           ` Eric Dumazet
2011-11-16 22:15 ` [PATCH net-next v6 4/9] net: new counter for tx_timeout errors in sysfs David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 5/9] forcedeth: Add messages to indicate using MSI or MSI-X David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 6/9] forcedeth: allow to silence "TX timeout" debug messages David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 7/9] forcedeth: implement ndo_get_stats64() API David Decotigny
2011-11-17  6:34   ` Eric Dumazet [this message]
2011-11-17 17:39     ` David Decotigny
2011-11-17 17:47       ` Eric Dumazet
2011-11-16 22:15 ` [PATCH net-next v6 8/9] forcedeth: account for dropped RX frames David Decotigny
2011-11-16 22:15 ` [PATCH net-next v6 9/9] forcedeth: stats updated with a deferrable timer David Decotigny

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=1321511678.3274.30.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=AAbdulla@nvidia.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=david.decotigny@google.com \
    --cc=ian.campbell@citrix.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=joe@perches.com \
    --cc=jpirko@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rick.jones2@hp.com \
    --cc=szymon@janc.net.pl \
    /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