From: Brice Goglin <brice@myri.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Linux Network Development list <netdev@vger.kernel.org>
Subject: [PATCH net-next] myri10ge: force stats update in ethtool gstats
Date: Thu, 16 Apr 2009 14:23:56 +0200 [thread overview]
Message-ID: <49E7235C.4080601@myri.com> (raw)
Force a statistics update when our ethtool gstats routine
is called. Otherwise, ethtool will continue to read stale
stats until something forces an update by reading /proc/net/dev
This requires putting a lock around the stats update to guard
against 2 threads (one via ethtool, and one via procfs)
updating the stats at once.
Signed-off-by: Brice Goglin <brice@myri.com>
--- linux-tmp.20090327.1716.42/drivers/net/myri10ge/myri10ge.c 2009-03-24 10:50:10.000000000 +0100
+++ linux-tmp/drivers/net/myri10ge/myri10ge.c 2009-03-27 17:16:43.000000000 +0100
@@ -361,6 +361,8 @@ static inline void put_be32(__be32 val,
__raw_writel((__force __u32) val, (__force void __iomem *)p);
}
+static struct net_device_stats *myri10ge_get_stats(struct net_device *dev);
+
static int
myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
struct myri10ge_cmd *data, int atomic)
@@ -1803,6 +1805,8 @@ myri10ge_get_ethtool_stats(struct net_de
int slice;
int i;
+ /* force stats update */
+ (void)myri10ge_get_stats(netdev);
for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
data[i] = ((unsigned long *)&mgp->stats)[i];
@@ -2968,6 +2972,7 @@ static struct net_device_stats *myri10ge
struct net_device_stats *stats = &mgp->stats;
int i;
+ spin_lock(&mgp->stats_lock);
memset(stats, 0, sizeof(*stats));
for (i = 0; i < mgp->num_slices; i++) {
slice_stats = &mgp->ss[i].stats;
@@ -2978,6 +2983,7 @@ static struct net_device_stats *myri10ge
stats->rx_dropped += slice_stats->rx_dropped;
stats->tx_dropped += slice_stats->tx_dropped;
}
+ spin_unlock(&mgp->stats_lock);
return stats;
}
@@ -3901,6 +3907,7 @@ static int myri10ge_probe(struct pci_dev
setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
(unsigned long)mgp);
+ spin_lock_init(&mgp->stats_lock);
SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
status = register_netdev(netdev);
next reply other threads:[~2009-04-16 12:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-16 12:23 Brice Goglin [this message]
2009-04-17 0:57 ` [PATCH net-next] myri10ge: force stats update in ethtool gstats 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=49E7235C.4080601@myri.com \
--to=brice@myri.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 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).