* [PATCH net-next-2.6] vxge: Implement 64bit stats
@ 2010-08-18 13:42 Eric Dumazet
2010-08-18 15:25 ` Jon Mason
2010-08-18 22:53 ` Jon Mason
0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2010-08-18 13:42 UTC (permalink / raw)
To: David Miller
Cc: netdev, Ramkrishna Vepa, Sivakumar Subramani, Sreenivasa Honnur,
Jon Mason
vxge_get_stats() is racy, since it clears a block of memory (net_stats)
possibly still used by other cpus.
We can update this driver to full 64bit stats, since ndo_get_stats64()
provides a private block to store results, and driver maintains 64bit
counters already.
We also remove net_stats field from struct vxge_sw_stats
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
drivers/net/vxge/vxge-main.c | 22 +++++++---------------
drivers/net/vxge/vxge-main.h | 1 -
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index c7c5605..ac90196 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -2914,26 +2914,18 @@ static int vxge_change_mtu(struct net_device *dev, int new_mtu)
}
/**
- * vxge_get_stats
+ * vxge_get_stats64
* @dev: pointer to the device structure
+ * @stats: pointer to struct rtnl_link_stats64
*
- * Updates the device statistics structure. This function updates the device
- * statistics structure in the net_device structure and returns a pointer
- * to the same.
*/
-static struct net_device_stats *
-vxge_get_stats(struct net_device *dev)
+static struct rtnl_link_stats64 *
+vxge_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
{
- struct vxgedev *vdev;
- struct net_device_stats *net_stats;
+ struct vxgedev *vdev = netdev_priv(dev);
int k;
- vdev = netdev_priv(dev);
-
- net_stats = &vdev->stats.net_stats;
-
- memset(net_stats, 0, sizeof(struct net_device_stats));
-
+ /* net_stats already zeroed by caller */
for (k = 0; k < vdev->no_of_vpath; k++) {
net_stats->rx_packets += vdev->vpaths[k].ring.stats.rx_frms;
net_stats->rx_bytes += vdev->vpaths[k].ring.stats.rx_bytes;
@@ -3102,7 +3094,7 @@ vxge_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
static const struct net_device_ops vxge_netdev_ops = {
.ndo_open = vxge_open,
.ndo_stop = vxge_close,
- .ndo_get_stats = vxge_get_stats,
+ .ndo_get_stats64 = vxge_get_stats64,
.ndo_start_xmit = vxge_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_multicast_list = vxge_set_multicast,
diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h
index 2e3b064..d4be07e 100644
--- a/drivers/net/vxge/vxge-main.h
+++ b/drivers/net/vxge/vxge-main.h
@@ -172,7 +172,6 @@ struct vxge_msix_entry {
struct vxge_sw_stats {
/* Network Stats (interface stats) */
- struct net_device_stats net_stats;
/* Tx */
u64 tx_frms;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next-2.6] vxge: Implement 64bit stats
2010-08-18 13:42 [PATCH net-next-2.6] vxge: Implement 64bit stats Eric Dumazet
@ 2010-08-18 15:25 ` Jon Mason
2010-08-18 15:28 ` Eric Dumazet
2010-08-18 22:53 ` Jon Mason
1 sibling, 1 reply; 5+ messages in thread
From: Jon Mason @ 2010-08-18 15:25 UTC (permalink / raw)
To: Eric Dumazet
Cc: David Miller, netdev, Ramkrishna Vepa, Sivakumar Subramani,
Sreenivasa Honnur
On Wed, Aug 18, 2010 at 06:42:54AM -0700, Eric Dumazet wrote:
> vxge_get_stats() is racy, since it clears a block of memory (net_stats)
> possibly still used by other cpus.
>
> We can update this driver to full 64bit stats, since ndo_get_stats64()
> provides a private block to store results, and driver maintains 64bit
> counters already.
>
> We also remove net_stats field from struct vxge_sw_stats
It looks sane. Assuming you have not tested it already, I'll give it a
quick sanity check.
Thanks,
Jon
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
> drivers/net/vxge/vxge-main.c | 22 +++++++---------------
> drivers/net/vxge/vxge-main.h | 1 -
> 2 files changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
> index c7c5605..ac90196 100644
> --- a/drivers/net/vxge/vxge-main.c
> +++ b/drivers/net/vxge/vxge-main.c
> @@ -2914,26 +2914,18 @@ static int vxge_change_mtu(struct net_device *dev, int new_mtu)
> }
>
> /**
> - * vxge_get_stats
> + * vxge_get_stats64
> * @dev: pointer to the device structure
> + * @stats: pointer to struct rtnl_link_stats64
> *
> - * Updates the device statistics structure. This function updates the device
> - * statistics structure in the net_device structure and returns a pointer
> - * to the same.
> */
> -static struct net_device_stats *
> -vxge_get_stats(struct net_device *dev)
> +static struct rtnl_link_stats64 *
> +vxge_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
> {
> - struct vxgedev *vdev;
> - struct net_device_stats *net_stats;
> + struct vxgedev *vdev = netdev_priv(dev);
> int k;
>
> - vdev = netdev_priv(dev);
> -
> - net_stats = &vdev->stats.net_stats;
> -
> - memset(net_stats, 0, sizeof(struct net_device_stats));
> -
> + /* net_stats already zeroed by caller */
> for (k = 0; k < vdev->no_of_vpath; k++) {
> net_stats->rx_packets += vdev->vpaths[k].ring.stats.rx_frms;
> net_stats->rx_bytes += vdev->vpaths[k].ring.stats.rx_bytes;
> @@ -3102,7 +3094,7 @@ vxge_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
> static const struct net_device_ops vxge_netdev_ops = {
> .ndo_open = vxge_open,
> .ndo_stop = vxge_close,
> - .ndo_get_stats = vxge_get_stats,
> + .ndo_get_stats64 = vxge_get_stats64,
> .ndo_start_xmit = vxge_xmit,
> .ndo_validate_addr = eth_validate_addr,
> .ndo_set_multicast_list = vxge_set_multicast,
> diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h
> index 2e3b064..d4be07e 100644
> --- a/drivers/net/vxge/vxge-main.h
> +++ b/drivers/net/vxge/vxge-main.h
> @@ -172,7 +172,6 @@ struct vxge_msix_entry {
>
> struct vxge_sw_stats {
> /* Network Stats (interface stats) */
> - struct net_device_stats net_stats;
>
> /* Tx */
> u64 tx_frms;
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next-2.6] vxge: Implement 64bit stats
2010-08-18 15:25 ` Jon Mason
@ 2010-08-18 15:28 ` Eric Dumazet
0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2010-08-18 15:28 UTC (permalink / raw)
To: Jon Mason
Cc: David Miller, netdev, Ramkrishna Vepa, Sivakumar Subramani,
Sreenivasa Honnur
Le mercredi 18 août 2010 à 10:25 -0500, Jon Mason a écrit :
> On Wed, Aug 18, 2010 at 06:42:54AM -0700, Eric Dumazet wrote:
> > vxge_get_stats() is racy, since it clears a block of memory (net_stats)
> > possibly still used by other cpus.
> >
> > We can update this driver to full 64bit stats, since ndo_get_stats64()
> > provides a private block to store results, and driver maintains 64bit
> > counters already.
> >
> > We also remove net_stats field from struct vxge_sw_stats
>
> It looks sane. Assuming you have not tested it already, I'll give it a
> quick sanity check.
I did not test it, I would be grateful if you can do this ;)
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next-2.6] vxge: Implement 64bit stats
2010-08-18 13:42 [PATCH net-next-2.6] vxge: Implement 64bit stats Eric Dumazet
2010-08-18 15:25 ` Jon Mason
@ 2010-08-18 22:53 ` Jon Mason
2010-08-19 7:17 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Jon Mason @ 2010-08-18 22:53 UTC (permalink / raw)
To: Eric Dumazet
Cc: David Miller, netdev, Ramkrishna Vepa, Sivakumar Subramani,
Sreenivasa Honnur
On Wed, Aug 18, 2010 at 06:42:54AM -0700, Eric Dumazet wrote:
> vxge_get_stats() is racy, since it clears a block of memory (net_stats)
> possibly still used by other cpus.
>
> We can update this driver to full 64bit stats, since ndo_get_stats64()
> provides a private block to store results, and driver maintains 64bit
> counters already.
>
> We also remove net_stats field from struct vxge_sw_stats
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Jon Mason <jon.mason@exar.com>
> ---
> drivers/net/vxge/vxge-main.c | 22 +++++++---------------
> drivers/net/vxge/vxge-main.h | 1 -
> 2 files changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
> index c7c5605..ac90196 100644
> --- a/drivers/net/vxge/vxge-main.c
> +++ b/drivers/net/vxge/vxge-main.c
> @@ -2914,26 +2914,18 @@ static int vxge_change_mtu(struct net_device *dev, int new_mtu)
> }
>
> /**
> - * vxge_get_stats
> + * vxge_get_stats64
> * @dev: pointer to the device structure
> + * @stats: pointer to struct rtnl_link_stats64
> *
> - * Updates the device statistics structure. This function updates the device
> - * statistics structure in the net_device structure and returns a pointer
> - * to the same.
> */
> -static struct net_device_stats *
> -vxge_get_stats(struct net_device *dev)
> +static struct rtnl_link_stats64 *
> +vxge_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
> {
> - struct vxgedev *vdev;
> - struct net_device_stats *net_stats;
> + struct vxgedev *vdev = netdev_priv(dev);
> int k;
>
> - vdev = netdev_priv(dev);
> -
> - net_stats = &vdev->stats.net_stats;
> -
> - memset(net_stats, 0, sizeof(struct net_device_stats));
> -
> + /* net_stats already zeroed by caller */
> for (k = 0; k < vdev->no_of_vpath; k++) {
> net_stats->rx_packets += vdev->vpaths[k].ring.stats.rx_frms;
> net_stats->rx_bytes += vdev->vpaths[k].ring.stats.rx_bytes;
> @@ -3102,7 +3094,7 @@ vxge_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
> static const struct net_device_ops vxge_netdev_ops = {
> .ndo_open = vxge_open,
> .ndo_stop = vxge_close,
> - .ndo_get_stats = vxge_get_stats,
> + .ndo_get_stats64 = vxge_get_stats64,
> .ndo_start_xmit = vxge_xmit,
> .ndo_validate_addr = eth_validate_addr,
> .ndo_set_multicast_list = vxge_set_multicast,
> diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h
> index 2e3b064..d4be07e 100644
> --- a/drivers/net/vxge/vxge-main.h
> +++ b/drivers/net/vxge/vxge-main.h
> @@ -172,7 +172,6 @@ struct vxge_msix_entry {
>
> struct vxge_sw_stats {
> /* Network Stats (interface stats) */
> - struct net_device_stats net_stats;
>
> /* Tx */
> u64 tx_frms;
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next-2.6] vxge: Implement 64bit stats
2010-08-18 22:53 ` Jon Mason
@ 2010-08-19 7:17 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-08-19 7:17 UTC (permalink / raw)
To: jon.mason
Cc: eric.dumazet, netdev, Ramkrishna.Vepa, Sivakumar.Subramani,
Sreenivasa.Honnur
From: Jon Mason <jon.mason@exar.com>
Date: Wed, 18 Aug 2010 17:53:31 -0500
> On Wed, Aug 18, 2010 at 06:42:54AM -0700, Eric Dumazet wrote:
>> vxge_get_stats() is racy, since it clears a block of memory (net_stats)
>> possibly still used by other cpus.
>>
>> We can update this driver to full 64bit stats, since ndo_get_stats64()
>> provides a private block to store results, and driver maintains 64bit
>> counters already.
>>
>> We also remove net_stats field from struct vxge_sw_stats
>>
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Acked-by: Jon Mason <jon.mason@exar.com>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-19 7:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-18 13:42 [PATCH net-next-2.6] vxge: Implement 64bit stats Eric Dumazet
2010-08-18 15:25 ` Jon Mason
2010-08-18 15:28 ` Eric Dumazet
2010-08-18 22:53 ` Jon Mason
2010-08-19 7:17 ` David Miller
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).