* [RFC 1/2] igb: statistic optimization
@ 2008-10-21 19:09 Stephen Hemminger
2008-10-21 19:30 ` Brandeburg, Jesse
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2008-10-21 19:09 UTC (permalink / raw)
To: jeffery.t.kirsher, jesse.brandeburg, bruce.w.allan,
peter.p.waskiewicz.jr
Cc: e1000-devel, netdev
The network statistics were being updated by multiple CPU's causing cache
line bounces. Since this driver already keeps statistics per ring, use
those to compute the bytes/packet statistics.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Compile tested only, evaluation in progress
--- a/drivers/net/igb/igb_main.c 2008-10-21 08:57:11.000000000 -0700
+++ b/drivers/net/igb/igb_main.c 2008-10-21 09:05:43.000000000 -0700
@@ -3029,9 +3029,27 @@ static struct net_device_stats *
igb_get_stats(struct net_device *netdev)
{
struct igb_adapter *adapter = netdev_priv(netdev);
+ struct net_device_stats *stats = &adapter->net_stats;
+ int i;
+
+ stats->tx_bytes = 0;
+ stats->tx_packets = 0;
+ for (i = 0; i < adapter->num_tx_queues; i++) {
+ struct igb_ring *tx_ring = &adapter->tx_ring[i];
+ stats->tx_bytes += tx_ring->tx_stats.bytes;
+ stats->tx_packets += tx_ring->tx_stats.packets;
+ }
+ stats->rx_bytes = 0;
+ stats->rx_packets = 0;
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ struct igb_ring *rx_ring = &adapter->rx_ring[i];
+ stats->rx_bytes += rx_ring->rx_stats.bytes;
+ stats->rx_packets += rx_ring->rx_stats.packets;
+ }
+
+ igb_update_stats(adapter);
- /* only return the current stats */
- return &adapter->net_stats;
+ return stats;
}
/**
@@ -3711,8 +3729,6 @@ done_cleaning:
tx_ring->total_packets += total_packets;
tx_ring->tx_stats.bytes += total_bytes;
tx_ring->tx_stats.packets += total_packets;
- adapter->net_stats.tx_bytes += total_bytes;
- adapter->net_stats.tx_packets += total_packets;
return retval;
}
@@ -3953,8 +3969,6 @@ next_desc:
rx_ring->total_bytes += total_bytes;
rx_ring->rx_stats.packets += total_packets;
rx_ring->rx_stats.bytes += total_bytes;
- adapter->net_stats.rx_bytes += total_bytes;
- adapter->net_stats.rx_packets += total_packets;
return cleaned;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC 1/2] igb: statistic optimization 2008-10-21 19:09 [RFC 1/2] igb: statistic optimization Stephen Hemminger @ 2008-10-21 19:30 ` Brandeburg, Jesse 2008-10-21 19:31 ` Waskiewicz Jr, Peter P 2008-10-22 17:37 ` Rick Jones 0 siblings, 2 replies; 5+ messages in thread From: Brandeburg, Jesse @ 2008-10-21 19:30 UTC (permalink / raw) To: Stephen Hemminger Cc: jeffery.t.kirsher@intel.com, Brandeburg, Jesse, Allan, Bruce W, Waskiewicz Jr, Peter P, e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org On Tue, 21 Oct 2008, Stephen Hemminger wrote: > The network statistics were being updated by multiple CPU's causing cache > line bounces. Since this driver already keeps statistics per ring, use > those to compute the bytes/packet statistics. > > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Yeah, this is code we developed for e1000(e) and that was for only one queue, it should be a problem, and we should fix it one way or another. Thanks Stephen, everything seems good after a quick review, except for one note: see below. > Compile tested only, evaluation in progress okay > --- a/drivers/net/igb/igb_main.c 2008-10-21 08:57:11.000000000 -0700 > +++ b/drivers/net/igb/igb_main.c 2008-10-21 09:05:43.000000000 -0700 > @@ -3029,9 +3029,27 @@ static struct net_device_stats * > igb_get_stats(struct net_device *netdev) > { > struct igb_adapter *adapter = netdev_priv(netdev); > + struct net_device_stats *stats = &adapter->net_stats; > + int i; > + > + stats->tx_bytes = 0; > + stats->tx_packets = 0; > + for (i = 0; i < adapter->num_tx_queues; i++) { > + struct igb_ring *tx_ring = &adapter->tx_ring[i]; > + stats->tx_bytes += tx_ring->tx_stats.bytes; > + stats->tx_packets += tx_ring->tx_stats.packets; > + } > + stats->rx_bytes = 0; > + stats->rx_packets = 0; > + for (i = 0; i < adapter->num_rx_queues; i++) { > + struct igb_ring *rx_ring = &adapter->rx_ring[i]; > + stats->rx_bytes += rx_ring->rx_stats.bytes; > + stats->rx_packets += rx_ring->rx_stats.packets; > + } > + > + igb_update_stats(adapter); I don't think you want to put this in the code that can be called directly from IOCTL from userspace. This function can take a lot of cycles and some silly applications like gkrellm call it quite frequently. The update_stats function will be called as part of the watchdog anyway, and you already got the interesting stats for realtime with the tx and rx bytes/packets. > - /* only return the current stats */ > - return &adapter->net_stats; > + return stats; > } > > /** > @@ -3711,8 +3729,6 @@ done_cleaning: > tx_ring->total_packets += total_packets; > tx_ring->tx_stats.bytes += total_bytes; > tx_ring->tx_stats.packets += total_packets; > - adapter->net_stats.tx_bytes += total_bytes; > - adapter->net_stats.tx_packets += total_packets; > return retval; > } > > @@ -3953,8 +3969,6 @@ next_desc: > rx_ring->total_bytes += total_bytes; > rx_ring->rx_stats.packets += total_packets; > rx_ring->rx_stats.bytes += total_bytes; > - adapter->net_stats.rx_bytes += total_bytes; > - adapter->net_stats.rx_packets += total_packets; > return cleaned; > } The same thing should be done to ixgbe too, but I'm just mentioning it for posterity, not because I'd expect you to do so. ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [RFC 1/2] igb: statistic optimization 2008-10-21 19:30 ` Brandeburg, Jesse @ 2008-10-21 19:31 ` Waskiewicz Jr, Peter P 2008-10-22 17:37 ` Rick Jones 1 sibling, 0 replies; 5+ messages in thread From: Waskiewicz Jr, Peter P @ 2008-10-21 19:31 UTC (permalink / raw) To: Brandeburg, Jesse, Stephen Hemminger Cc: jeffery.t.kirsher@intel.com, Allan, Bruce W, e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org > The same thing should be done to ixgbe too, but I'm just mentioning it for > posterity, not because I'd expect you to do so. I've already got it on my list. -PJ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC 1/2] igb: statistic optimization 2008-10-21 19:30 ` Brandeburg, Jesse 2008-10-21 19:31 ` Waskiewicz Jr, Peter P @ 2008-10-22 17:37 ` Rick Jones 2008-10-22 17:54 ` Stephen Hemminger 1 sibling, 1 reply; 5+ messages in thread From: Rick Jones @ 2008-10-22 17:37 UTC (permalink / raw) To: Brandeburg, Jesse Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org, Waskiewicz Jr, Peter P, Allan, Bruce W, jeffery.t.kirsher@intel.com, Stephen Hemminger > I don't think you want to put this in the code that can be called directly > from IOCTL from userspace. This function can take a lot of cycles and > some silly applications like gkrellm call it quite frequently. The > update_stats function will be called as part of the watchdog anyway, and > you already got the interesting stats for realtime with the tx and rx > bytes/packets. On the flip side aren't there "out of phase" issues with pulling stats based on a timer vs something like a netstat -i 1 command? rick jones ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC 1/2] igb: statistic optimization 2008-10-22 17:37 ` Rick Jones @ 2008-10-22 17:54 ` Stephen Hemminger 0 siblings, 0 replies; 5+ messages in thread From: Stephen Hemminger @ 2008-10-22 17:54 UTC (permalink / raw) To: Rick Jones Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org, Waskiewicz Jr, Peter P, Allan, Bruce W, Brandeburg, Jesse, jeffery.t.kirsher@intel.com On Wed, 22 Oct 2008 10:37:44 -0700 Rick Jones <rick.jones2@hp.com> wrote: > > I don't think you want to put this in the code that can be called directly > > from IOCTL from userspace. This function can take a lot of cycles and > > some silly applications like gkrellm call it quite frequently. The > > update_stats function will be called as part of the watchdog anyway, and > > you already got the interesting stats for realtime with the tx and rx > > bytes/packets. > > On the flip side aren't there "out of phase" issues with pulling stats > based on a timer vs something like a netstat -i 1 command? > > rick jones The only stats pulled are the error stats, so this is probably okay. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-22 17:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-21 19:09 [RFC 1/2] igb: statistic optimization Stephen Hemminger 2008-10-21 19:30 ` Brandeburg, Jesse 2008-10-21 19:31 ` Waskiewicz Jr, Peter P 2008-10-22 17:37 ` Rick Jones 2008-10-22 17:54 ` Stephen Hemminger
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).