Skip to contentSkip to conversation

net: Node aware multipath device round robin

PATCH New Ravikiran G Thirumalai 1 participant 2 messages Mar 22, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net: Node aware multipath device round robin

Following patch adds in node aware, device round robin ip multipathing. It is based on multipath_drr.c, the multipath device round robin algorithm, and is derived from it. This implementation maintians per node state table, and round robins between interfaces on the same node. The implementation needs to be aware of the NIC proximity to a node. Hence we have added a nodeid field to struct netdevice. NIC device drivers can initialize this with the node id the NIC belongs to. This patch uses IP_MP_ALG_DRR slot like the regular multipath_drr too. So either SMP multipath_drr or node aware multipath_node_drr should be used for device round robin, based on system having proximity information for the NICs.

Performance results:
1. Single NIC test -- 1 client targets 1 nic on the server with 300 concurrent
requests.
2. 4 NIC test -- 1 client targets 4 nics, all on different nodes on the server with 300 concurrent requests.

We see about 135% improvement on AB requests per second with this patch and the device_locality_check patch on single NIC test, on the Rackable c5100 machine (server). We see about 64% improvement when all 4 NICS are targeted.

Credits: This work was originally done by Justin Forbes

Comments?

Signed-off by: Pravin B. Shelar <[email protected]> Signed-off by: Shobhit Dayal <[email protected]> Signed-off by: Ravikiran Thirumalai <[email protected]> Signed-off by: Shai Fultheim <[email protected]>

drivers/net/e1000/e1000_main.c +1 -0
Index: linux-2.6.16/drivers/net/e1000/e1000_main.c
===================================================================
@@ -692,6 +692,7 @@ e1000_probe(struct pci_dev *pdev,
 
 	SET_MODULE_OWNER(netdev);
 	SET_NETDEV_DEV(netdev, &pdev->dev);
+	SET_NETDEV_NODE(netdev, pcibus_to_node(pdev->bus));
 
 	pci_set_drvdata(pdev, netdev);
 	adapter = netdev_priv(netdev);
drivers/net/tg3.c +1 -0
Index: linux-2.6.16/drivers/net/tg3.c
===================================================================
@@ -10705,6 +10705,7 @@ static int __devinit tg3_init_one(struct
 
 	SET_MODULE_OWNER(dev);
 	SET_NETDEV_DEV(dev, &pdev->dev);
+	SET_NETDEV_NODE(dev, pcibus_to_node(pdev->bus));
 
 	dev->features |= NETIF_F_LLTX;
 #if TG3_VLAN_TAG_USED
include/linux/netdevice.h +11 -1
Index: linux-2.6.16/include/linux/netdevice.h
===================================================================
@@ -315,7 +315,9 @@ struct net_device
 	/* Interface index. Unique device identifier	*/
 	int			ifindex;
 	int			iflink;
-
+#ifdef CONFIG_NUMA
+	int			node;	/* NUMA node this IF is close to */
+#endif
 
 	struct net_device_stats* (*get_stats)(struct net_device *dev);
 	struct iw_statistics*	(*get_wireless_stats)(struct net_device *dev);
@@ -520,6 +522,14 @@ static inline void *netdev_priv(struct n
  */
 #define SET_NETDEV_DEV(net, pdev)	((net)->class_dev.dev = (pdev))
 
+#ifdef CONFIG_NUMA
+#define SET_NETDEV_NODE(dev, nodeid)	((dev)->node = (nodeid))
+#define netdev_node(dev)		((dev)->node)
+#else
+#define SET_NETDEV_NODE(dev, nodeid)	do {} while (0)
+#define netdev_node(dev)		(-1)
+#endif
+
 struct packet_type {
 	__be16			type;	/* This is really htons(ether_type). */
 	struct net_device	*dev;	/* NULL is wildcarded here	     */
net/core/dev.c +2 -1
Index: linux-2.6.16/net/core/dev.c
===================================================================
@@ -3003,7 +3003,8 @@ struct net_device *alloc_netdev(int size
 
 	if (sizeof_priv)
 		dev->priv = netdev_priv(dev);
-
+	
+	SET_NETDEV_NODE(dev, -1);
 	setup(dev);
 	strcpy(dev->name, name);
 	return dev;
net/ipv4/Kconfig +9 -0
Index: linux-2.6.16/net/ipv4/Kconfig
===================================================================
@@ -164,6 +164,15 @@ config IP_ROUTE_MULTIPATH_DRR
 	  available interfaces. This policy makes sense if the connections 
 	  should be primarily distributed on interfaces and not on routes. 
 
+config IP_ROUTE_MULTIPATH_NODE
+	tristate "MULTIPATH: interface RR algorithm with node affinity"
+	depends on IP_ROUTE_MULTIPATH_CACHED && NUMA && !IP_ROUTE_MULTIPATH_DRR
+	help
+	  This allows equal cost multipath device round robin alogorithm  to
+	  use node affinity when choosing the device for outbound traffic. This
+	  is similar to CONFIG_IP_ROUTE_MULTIPATH_DRR. Choose this if you
+	  have a NUMA system, and the NICs have node proximity.
+
 config IP_ROUTE_VERBOSE
 	bool "IP: verbose route monitoring"
 	depends on IP_ADVANCED_ROUTER
net/ipv4/Makefile +1 -0
Index: linux-2.6.16/net/ipv4/Makefile
===================================================================
@@ -28,6 +28,7 @@ obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += m
 obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o
 obj-$(CONFIG_IP_ROUTE_MULTIPATH_WRANDOM) += multipath_wrandom.o
 obj-$(CONFIG_IP_ROUTE_MULTIPATH_DRR) += multipath_drr.o
+obj-$(CONFIG_IP_ROUTE_MULTIPATH_NODE) += multipath_node_drr.o
 obj-$(CONFIG_NETFILTER)	+= netfilter.o netfilter/
 obj-$(CONFIG_IP_VS) += ipvs/
 obj-$(CONFIG_INET_DIAG) += inet_diag.o 
net/ipv4/multipath_node_drr.c +264 -0

264 lines not on this page · raw message

#1 lore raw

PATCH 2/2 net: Node aware multipath device round robin -- device locality check

This patch checks device locality on every ip packet xmit.
In multipath configuration tcp connection to route association is done at session startup time. The tcp session process is migrated to different nodes after this association. This would mean a remote NIC is chosen for xmit,
although a local NIC could be available. Following patch checks if a
local NIC is available for the desitnation, and recalculates routes if so. his leads to remote NIC transfer in some tcp work load such as AB.

Downside: adds a bitmap to struct rtable. But only if CONFIG_IP_ROUTE_MULTIPATH_NODE is enabled.

Comments, suggestions welcome.

Signed-off by: Pravin B. Shelar <[email protected]> Signed-off by: Ravikiran Thirumalai <[email protected]> Signed-off by: Shai Fultheim <[email protected]>

include/net/route.h +24 -0
Index: linux-2.6.16/include/net/route.h
===================================================================
@@ -75,6 +75,13 @@ struct rtable
 	/* Miscellaneous cached information */
 	__u32			rt_spec_dst; /* RFC1122 specific destination */
 	struct inet_peer	*peer; /* long-living peer info */
+#ifdef CONFIG_IP_ROUTE_MULTIPATH_NODE
+	/*  bitmap bit is set if current node has a local multi-path device for
+	 *  this route.
+	 */
+	DECLARE_BITMAP          (mp_if_bitmap, MAX_NUMNODES);
+#endif
+
 };
 
 struct ip_rt_acct
@@ -201,4 +208,21 @@ static inline struct inet_peer *rt_get_p
 
 extern ctl_table ipv4_route_table[];
 
+#ifdef CONFIG_IP_ROUTE_MULTIPATH_NODE
+
+#include <linux/ip_mp_alg.h>
+
+static inline int dst_dev_node_check(struct rtable *rt)
+{
+	int cnode = numa_node_id();
+	if (unlikely(netdev_node(rt->u.dst.dev) != cnode)) {
+		if (test_bit(cnode, rt->mp_if_bitmap))
+			return 1;
+	}
+	return 0;
+}
+#else
+#define dst_dev_node_check(rt)			0
+#endif
+
 #endif	/* _ROUTE_H */
net/ipv4/ip_output.c +1 -1
Index: linux-2.6.16/net/ipv4/ip_output.c
===================================================================
@@ -309,7 +309,7 @@ int ip_queue_xmit(struct sk_buff *skb, i
 
 	/* Make sure we can route this packet. */
 	rt = (struct rtable *)__sk_dst_check(sk, 0);
-	if (rt == NULL) {
+	if ((rt == NULL ) || dst_dev_node_check(rt)) {
 		u32 daddr;
 
 		/* Use correct destination address if we have options. */
net/ipv4/route.c +20 -0
Index: linux-2.6.16/net/ipv4/route.c
===================================================================
@@ -2313,6 +2313,22 @@ static inline int ip_mkroute_output(stru
 	if (res->fi && res->fi->fib_nhs > 1) {
 		unsigned char hopcount = res->fi->fib_nhs;
 
+#ifdef CONFIG_IP_ROUTE_MULTIPATH_NODE
+		DECLARE_BITMAP (mp_if_bitmap, MAX_NUMNODES);
+		bitmap_zero(mp_if_bitmap, MAX_NUMNODES);
+		/* Calculating device bitmap for this multipath route */
+		if (res->fi->fib_mp_alg == IP_MP_ALG_DRR) {
+			for (hop = 0; hop < hopcount; hop++) {
+				struct net_device *dev2nexthop;
+
+				res->nh_sel = hop;
+				dev2nexthop = FIB_RES_DEV(*res);
+				dev_hold(dev2nexthop);
+				set_bit(netdev_node(dev2nexthop), mp_if_bitmap);
+				dev_put(dev2nexthop);
+			}
+		}
+#endif
 		for (hop = 0; hop < hopcount; hop++) {
 			struct net_device *dev2nexthop;
 
@@ -2343,6 +2359,10 @@ static inline int ip_mkroute_output(stru
 					     FIB_RES_NETMASK(*res),
 					     res->prefixlen,
 					     &FIB_RES_NH(*res));
+
+#ifdef CONFIG_IP_ROUTE_MULTIPATH_NODE
+			bitmap_copy(rth->mp_if_bitmap, mp_if_bitmap, MAX_NUMNODES);
+#endif
 		cleanup:
 			/* release work reference to output device */
 			dev_put(dev2nexthop);