From: Stephen Hemminger <shemminger@vyatta.com>
To: davem@davemloft.net, Amit Kumar Salecha <amit.salecha@qlogic.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 3/5] netxen: make 64 bit stats safe on 32 bit platform
Date: Mon, 20 Jun 2011 13:35:09 -0700 [thread overview]
Message-ID: <20110620203602.836836605@vyatta.com> (raw)
In-Reply-To: 20110620203506.363818794@vyatta.com
[-- Attachment #1: netxen-stats-sync.patch --]
[-- Type: text/plain, Size: 2491 bytes --]
Use stats_update wrapper to avoid problems where 64 bit statistic update
is not atomic on 32 bit platform.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
drivers/net/netxen/netxen_nic.h | 1 +
drivers/net/netxen/netxen_nic_init.c | 2 ++
drivers/net/netxen/netxen_nic_main.c | 16 ++++++++++++----
3 files changed, 15 insertions(+), 4 deletions(-)
--- a/drivers/net/netxen/netxen_nic.h 2011-06-20 12:42:05.035994241 -0700
+++ b/drivers/net/netxen/netxen_nic.h 2011-06-20 12:51:27.727993925 -0700
@@ -607,6 +607,7 @@ struct netxen_hardware_context {
#define ETHERNET_FCS_SIZE 4
struct netxen_adapter_stats {
+ struct u64_stats_sync syncp;
u64 xmitcalled;
u64 xmitfinished;
u64 rxdropped;
--- a/drivers/net/netxen/netxen_nic_init.c 2011-06-20 12:48:02.963994039 -0700
+++ b/drivers/net/netxen/netxen_nic_init.c 2011-06-20 12:50:27.887993959 -0700
@@ -1616,8 +1616,10 @@ netxen_process_lro(struct netxen_adapter
netif_receive_skb(skb);
+ u64_stats_update_begin(&adapter->stats.syncp);
adapter->stats.lro_pkts++;
adapter->stats.rxbytes += length;
+ u64_stats_update_end(&adapter->stats.syncp);
return buffer;
}
--- a/drivers/net/netxen/netxen_nic_main.c 2011-06-20 12:41:47.739994250 -0700
+++ b/drivers/net/netxen/netxen_nic_main.c 2011-06-20 12:52:49.255993879 -0700
@@ -1968,8 +1968,10 @@ netxen_nic_xmit_frame(struct sk_buff *sk
netxen_nic_update_cmd_producer(adapter, tx_ring);
+ u64_stats_update_begin(&adapter->stats.syncp);
adapter->stats.txbytes += skb->len;
adapter->stats.xmitcalled++;
+ u64_stats_update_end(&adapter->stats.syncp);
return NETDEV_TX_OK;
@@ -2115,11 +2117,17 @@ static struct rtnl_link_stats64 *netxen_
struct rtnl_link_stats64 *stats)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
+ unsigned int start;
+
+ do {
+ start = u64_stats_fetch_begin(&adapter->stats.syncp);
+
+ stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts;
+ stats->tx_packets = adapter->stats.xmitfinished;
+ stats->rx_bytes = adapter->stats.rxbytes;
+ stats->tx_bytes = adapter->stats.txbytes;
+ } while (u64_stats_fetch_retry(&adapter->stats.syncp, start));
- stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts;
- stats->tx_packets = adapter->stats.xmitfinished;
- stats->rx_bytes = adapter->stats.rxbytes;
- stats->tx_bytes = adapter->stats.txbytes;
stats->rx_dropped = adapter->stats.rxdropped;
stats->tx_dropped = adapter->stats.txdropped;
next prev parent reply other threads:[~2011-06-20 20: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
2011-06-20 21:52 ` Stephen Hemminger
2011-06-20 22:02 ` Eric Dumazet
2011-06-20 20:35 ` Stephen Hemminger [this message]
2011-06-20 21:50 ` [PATCH net-next 3/5] netxen: make 64 bit stats safe " 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=20110620203602.836836605@vyatta.com \
--to=shemminger@vyatta.com \
--cc=amit.salecha@qlogic.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.