[ovs-dev] [PATCH 3/6] netdev-vport: Use vport stats layer on 32-bit machines.

Jesse Gross jesse at nicira.com
Wed Jun 9 19:33:18 PDT 2010


Linux devices store stats in counters the size of a machine word,
which are rapidly overflowed on a 32-bit machine.  In this
situation we now use the vport stats layer, which always uses 64-
bit stats.  On 64-bit machines we continue to use the normal
Linux stats to avoid the extra overhead of counting twice.
---
 datapath/vport-netdev.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c
index 50c51ac..da1043a 100644
--- a/datapath/vport-netdev.c
+++ b/datapath/vport-netdev.c
@@ -57,6 +57,11 @@ netdev_init(void)
 	 * Parasites we are. */
 	br_handle_frame_hook = netdev_frame_hook;
 
+	/* If the native device stats aren't 64 bit use the vport stats
+	 * tracking instead. */
+	if (sizeof(((struct net_device_stats *)0)->rx_bytes) < sizeof(u64))
+		netdev_vport_ops.flags |= VPORT_F_GEN_STATS;
+
 	return 0;
 }
 
@@ -99,6 +104,16 @@ netdev_create(const char *name, const void __user *config)
 		goto error_put;
 	}
 
+	/* If we are using the vport stats layer initialize it to the current
+	 * values so we are roughly consistent with the device stats. */
+	if (netdev_vport_ops.flags & VPORT_F_GEN_STATS) {
+		struct odp_vport_stats stats;
+
+		err = netdev_get_stats(vport, &stats);
+		if (!err)
+			vport_set_stats(vport, &stats);
+	}
+
 	return vport;
 
 error_put:
-- 
1.7.0.4





More information about the dev mailing list