PERFORCE change 164847 for review

Marko Zec zec at FreeBSD.org
Mon Jun 22 11:28:40 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164847

Change 164847 by zec at zec_amdx4 on 2009/06/22 11:27:51

	V_irtualize flowtable sysctl knobs and counters.

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/net/flowtable.c#6 edit
.. //depot/projects/vimage-commit2/src/sys/net/vnet.h#25 edit

Differences ...

==== //depot/projects/vimage-commit2/src/sys/net/flowtable.c#6 (text+ko) ====

@@ -205,48 +205,55 @@
  * - support explicit connection state (currently only ad-hoc for DSR)
  * - V_ flowtable sysctls and nmbflows
  */
+#ifdef VIMAGE_GLOBALS
+int	flowtable_enable;
+static int flowtable_hits;
+static int flowtable_lookups;
+static int flowtable_misses;
+static int flowtable_frees;
+static int flowtable_free_checks;
+static int flowtable_max_depth;
+static int flowtable_collisions;
+static int flowtable_syn_expire;
+static int flowtable_udp_expire;
+static int flowtable_fin_wait_expire;
+static int flowtable_tcp_expire;
+static int flowtable_nmbflows;
+#endif
 SYSCTL_NODE(_net_inet, OID_AUTO, flowtable, CTLFLAG_RD, NULL, "flowtable");
-int	flowtable_enable = 1;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, enable, CTLFLAG_RW,
-    &flowtable_enable, 0, "enable flowtable caching.");
-static int flowtable_hits = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, hits, CTLFLAG_RD,
-    &flowtable_hits, 0, "# flowtable hits.");
-static int flowtable_lookups = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, lookups, CTLFLAG_RD,
-    &flowtable_lookups, 0, "# flowtable lookups.");
-static int flowtable_misses = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, misses, CTLFLAG_RD,
-    &flowtable_misses, 0, "#flowtable misses.");
-static int flowtable_frees = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, frees, CTLFLAG_RD,
-    &flowtable_frees, 0, "#flows freed.");
-static int flowtable_free_checks = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, free_checks, CTLFLAG_RD,
-    &flowtable_free_checks, 0, "#flows free checks.");
-static int flowtable_max_depth = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, max_depth, CTLFLAG_RD,
-    &flowtable_max_depth, 0, "max collision list length.");
-static int flowtable_collisions = 0;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, collisions, CTLFLAG_RD,
-    &flowtable_collisions, 0, "#flowtable collisions.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, enable, CTLFLAG_RW,
+    flowtable_enable, 0, "enable flowtable caching.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, hits, CTLFLAG_RD,
+    flowtable_hits, 0, "# flowtable hits.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, lookups,
+    CTLFLAG_RD, flowtable_lookups, 0, "# flowtable lookups.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, misses, CTLFLAG_RD,
+    flowtable_misses, 0, "#flowtable misses.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, frees, CTLFLAG_RD,
+    flowtable_frees, 0, "#flows freed.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, free_checks,
+    CTLFLAG_RD, flowtable_free_checks, 0, "#flows free checks.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, max_depth,
+    CTLFLAG_RD, flowtable_max_depth, 0, "max collision list length.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, collisions,
+    CTLFLAG_RD, flowtable_collisions, 0, "#flowtable collisions.");
 
 /*
  * XXX This does not end up updating timeouts at runtime
  * and only reflects the value for the last table added :-/
  */
-static int flowtable_syn_expire = SYN_IDLE;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, syn_expire, CTLFLAG_RW,
-    &flowtable_syn_expire, 0, "seconds after which to remove syn allocated flow.");
-static int flowtable_udp_expire = UDP_IDLE;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, udp_expire, CTLFLAG_RW,
-    &flowtable_udp_expire, 0, "seconds after which to remove flow allocated to UDP.");
-static int flowtable_fin_wait_expire = FIN_WAIT_IDLE;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, fin_wait_expire, CTLFLAG_RW,
-    &flowtable_fin_wait_expire, 0, "seconds after which to remove a flow in FIN_WAIT.");
-static int flowtable_tcp_expire = TCP_IDLE;
-SYSCTL_INT(_net_inet_flowtable, OID_AUTO, tcp_expire, CTLFLAG_RW,
-    &flowtable_tcp_expire, 0, "seconds after which to remove flow allocated to a TCP connection.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, syn_expire,
+    CTLFLAG_RW, flowtable_syn_expire, 0,
+    "seconds after which to remove syn allocated flow.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, udp_expire,
+    CTLFLAG_RW, flowtable_udp_expire, 0,
+    "seconds after which to remove flow allocated to UDP.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, fin_wait_expire,
+    CTLFLAG_RW, flowtable_fin_wait_expire, 0,
+    "seconds after which to remove a flow in FIN_WAIT.");
+SYSCTL_V_INT(V_NET, vnet_net, _net_inet_flowtable, OID_AUTO, tcp_expire,
+    CTLFLAG_RW, flowtable_tcp_expire, 0,
+    "seconds after which to remove flow allocated to a TCP connection.");
 
 
 /*
@@ -256,28 +263,28 @@
  * there is no reason why this could not be changed at runtime)
  * and thus (currently) needs to be set with a tunable.
  */
-static int nmbflows = 4096;
-
 static int
 sysctl_nmbflows(SYSCTL_HANDLER_ARGS)
 {
 	INIT_VNET_NET(curvnet);
 	int error, newnmbflows;
 
-	newnmbflows = nmbflows;
+	newnmbflows = V_flowtable_nmbflows;
 	error = sysctl_handle_int(oidp, &newnmbflows, 0, req); 
 	if (error == 0 && req->newptr) {
-		if (newnmbflows > nmbflows) {
-			nmbflows = newnmbflows;
-			uma_zone_set_max(V_flow_ipv4_zone, nmbflows);
-			uma_zone_set_max(V_flow_ipv6_zone, nmbflows);
+		if (newnmbflows > V_flowtable_nmbflows) {
+			V_flowtable_nmbflows = newnmbflows;
+			uma_zone_set_max(V_flow_ipv4_zone,
+			    V_flowtable_nmbflows);
+			uma_zone_set_max(V_flow_ipv6_zone,
+			    V_flowtable_nmbflows);
 		} else
 			error = EINVAL;
 	}
 	return (error);
 }
 SYSCTL_PROC(_net_inet_flowtable, OID_AUTO, nmbflows, CTLTYPE_INT|CTLFLAG_RW,
-    &nmbflows, 0, sysctl_nmbflows, "IU", "Maximum number of flows allowed");
+    0, 0, sysctl_nmbflows, "IU", "Maximum number of flows allowed");
 
 #ifndef RADIX_MPATH
 static void
@@ -341,7 +348,7 @@
 	struct udphdr *uh;
 	struct sctphdr *sh;
 
-	if (flowtable_enable == 0)
+	if (V_flowtable_enable == 0)
 		return (0);
 
 	key[1] = key[0] = 0;
@@ -522,7 +529,7 @@
 	} 
 	
 	depth = 0;
-	flowtable_collisions++;
+	V_flowtable_collisions++;
 	/*
 	 * find end of list and make sure that we were not
 	 * preempted by another thread handling this flow
@@ -548,8 +555,8 @@
 		fle = fle->f_next;
 	} 
 
-	if (depth > flowtable_max_depth)
-		flowtable_max_depth = depth;
+	if (depth > V_flowtable_max_depth)
+		V_flowtable_max_depth = depth;
 	fletail->f_next = newfle;
 	fle = newfle;
 skip:
@@ -588,6 +595,7 @@
 int
 flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro)
 {
+	INIT_VNET_NET(curvnet);
 	uint32_t key[9], hash;
 	struct flentry *fle;
 	uint16_t flags;
@@ -622,7 +630,7 @@
 	if (hash == 0 || (key[0] == 0 && (ft->ft_flags & FL_HASH_PORTS)))
 		return (ENOENT);
 
-	flowtable_lookups++;
+	V_flowtable_lookups++;
 	FL_ENTRY_LOCK(ft, hash);
 	if ((fle = FL_ENTRY(ft, hash)) == NULL) {
 		FL_ENTRY_UNLOCK(ft, hash);
@@ -637,7 +645,7 @@
 	    && (proto == fle->f_proto)
 	    && (rt->rt_flags & RTF_UP)
 	    && (rt->rt_ifp != NULL)) {
-		flowtable_hits++;
+		V_flowtable_hits++;
 		fle->f_uptime = time_uptime;
 		fle->f_flags |= flags;
 		ro->ro_rt = rt;
@@ -651,7 +659,7 @@
 	FL_ENTRY_UNLOCK(ft, hash);
 
 uncached:
-	flowtable_misses++;
+	V_flowtable_misses++;
 	/*
 	 * This bit of code ends up locking the
 	 * same route 3 times (just like ip_output + ether_output)
@@ -762,10 +770,10 @@
 	 * replacement after 5s of non-use
 	 */
 	if (flags & FL_HASH_PORTS) {
-		ft->ft_udp_idle = flowtable_udp_expire;
-		ft->ft_syn_idle = flowtable_syn_expire;
-		ft->ft_fin_wait_idle = flowtable_fin_wait_expire;
-		ft->ft_tcp_idle = flowtable_fin_wait_expire;
+		ft->ft_udp_idle = V_flowtable_udp_expire;
+		ft->ft_syn_idle = V_flowtable_syn_expire;
+		ft->ft_fin_wait_idle = V_flowtable_fin_wait_expire;
+		ft->ft_tcp_idle = V_flowtable_fin_wait_expire;
 	} else {
 		ft->ft_udp_idle = ft->ft_fin_wait_idle =
 		    ft->ft_syn_idle = ft->ft_tcp_idle = 30;
@@ -803,12 +811,26 @@
 {
 	INIT_VNET_NET(curvnet);
 
-	V_flow_ipv4_zone = uma_zcreate("ip4flow", sizeof(struct flentry_v4), NULL,
-	    NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);
-	V_flow_ipv6_zone = uma_zcreate("ip6flow", sizeof(struct flentry_v6), NULL,
-	    NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);	
-	uma_zone_set_max(V_flow_ipv4_zone, nmbflows);
-	uma_zone_set_max(V_flow_ipv6_zone, nmbflows);
+	V_flowtable_enable = 1;
+	V_flowtable_hits = 0;
+	V_flowtable_lookups = 0;
+	V_flowtable_misses = 0;
+	V_flowtable_frees = 0;
+	V_flowtable_free_checks = 0;
+	V_flowtable_max_depth = 0;
+	V_flowtable_collisions = 0;
+	V_flowtable_syn_expire = SYN_IDLE;
+	V_flowtable_udp_expire = UDP_IDLE;
+	V_flowtable_fin_wait_expire = FIN_WAIT_IDLE;
+	V_flowtable_tcp_expire = TCP_IDLE;
+	V_flowtable_nmbflows = 4096;
+
+	V_flow_ipv4_zone = uma_zcreate("ip4flow", sizeof(struct flentry_v4),
+	    NULL, NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);
+	V_flow_ipv6_zone = uma_zcreate("ip6flow", sizeof(struct flentry_v6),
+	    NULL, NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);	
+	uma_zone_set_max(V_flow_ipv4_zone, V_flowtable_nmbflows);
+	uma_zone_set_max(V_flow_ipv6_zone, V_flowtable_nmbflows);
 	return (0);
 }
 
@@ -849,6 +871,7 @@
 static void
 flowtable_free_stale(struct flowtable *ft)
 {
+	INIT_VNET_NET(curvnet);
 	int curbit = 0, count;
 	struct flentry *fle,  **flehead, *fleprev;
 	struct flentry *flefreehead, *flefreetail, *fletmp;
@@ -875,7 +898,7 @@
 		flehead = flowtable_entry(ft, curbit);
 		fle = fleprev = *flehead;
 
-		flowtable_free_checks++;
+		V_flowtable_free_checks++;
 #ifdef DIAGNOSTIC
 		if (fle == NULL && curbit > 0) {
 			log(LOG_ALERT,
@@ -926,7 +949,7 @@
 	while ((fle = flefreehead) != NULL) {
 		flefreehead = fle->f_next;
 		count++;
-		flowtable_frees++;
+		V_flowtable_frees++;
 		fle_free(fle);
 	}
 	if (bootverbose && count)

==== //depot/projects/vimage-commit2/src/sys/net/vnet.h#25 (text+ko) ====

@@ -53,17 +53,31 @@
 	struct if_clone *	_lo_cloner;
 	struct ifc_simple_data *_lo_cloner_data;
 
-	struct flowtable *	_flow_list_head;
-	uint32_t		_flow_hashjitter;
-	uma_zone_t		_flow_ipv4_zone;
-	uma_zone_t		_flow_ipv6_zone;
-
 	LIST_HEAD(, rawcb)	_rawcb_list;
 
 	LIST_HEAD(, if_clone)	_if_cloners;
 	int			_if_cloners_count;
 
 	int			_ether_ipfw;
+
+	struct flowtable *	_flow_list_head;
+	uint32_t		_flow_hashjitter;
+	uma_zone_t		_flow_ipv4_zone;
+	uma_zone_t		_flow_ipv6_zone;
+
+	int			_flowtable_enable;
+	int			_flowtable_hits;
+	int			_flowtable_lookups;
+	int			_flowtable_misses;
+	int			_flowtable_frees;
+	int			_flowtable_free_checks;
+	int			_flowtable_max_depth;
+	int			_flowtable_collisions;
+	int			_flowtable_syn_expire;
+	int			_flowtable_udp_expire;
+	int			_flowtable_fin_wait_expire;
+	int			_flowtable_tcp_expire;
+	int			_flowtable_nmbflows;
 };
 
 /* Size guard. See sys/vimage.h. */
@@ -88,6 +102,19 @@
 #define	V_flow_ipv4_zone	VNET_NET(flow_ipv4_zone)
 #define	V_flow_ipv6_zone	VNET_NET(flow_ipv6_zone)
 #define	V_flow_list_head	VNET_NET(flow_list_head)
+#define	V_flowtable_collisions	VNET_NET(flowtable_collisions)
+#define	V_flowtable_enable	VNET_NET(flowtable_enable)
+#define	V_flowtable_fin_wait_expire VNET_NET(flowtable_fin_wait_expire)
+#define	V_flowtable_free_checks	VNET_NET(flowtable_free_checks)
+#define	V_flowtable_frees	VNET_NET(flowtable_frees)
+#define	V_flowtable_hits	VNET_NET(flowtable_hits)
+#define	V_flowtable_lookups	VNET_NET(flowtable_lookups)
+#define	V_flowtable_max_depth	VNET_NET(flowtable_max_depth)
+#define	V_flowtable_misses	VNET_NET(flowtable_misses)
+#define	V_flowtable_nmbflows	VNET_NET(flowtable_nmbflows)
+#define	V_flowtable_syn_expire	VNET_NET(flowtable_syn_expire)
+#define	V_flowtable_tcp_expire	VNET_NET(flowtable_tcp_expire)
+#define	V_flowtable_udp_expire	VNET_NET(flowtable_udp_expire)
 #define	V_if_index		VNET_NET(if_index)
 #define	V_if_indexlim		VNET_NET(if_indexlim)
 #define	V_if_cloners		VNET_NET(if_cloners)


More information about the p4-projects mailing list