Skip to contentSkip to conversation

e1000e: NUMA changes, add Node= parameter

RFC PATCH In review Jeff Kirsher 4 participants 4 messages Sep 23, 2010

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

RFC PATCH 1/1 e1000e: NUMA changes, add Node= parameter

From: Jesse Brandeburg <[email protected]>

NUMA changes associated with routing performance on 82571 and x58/S5500 chipsets. Patch allows user to set new Node= parameter that controls driver memory allocations for any port to a single cpu/memory complex. Since e1000e does not support multiple queues this is a (relatively) simple implementation.

Although a module parameter is not the preferred way for in-tree modules, this problem is not solvable in ethtool without mod params because of needing the information at probe time to control early allocations of memory. Ideally there would even be a way to control the node where the memory of the netdev struct would be allocated also.

Special thanks to Emil Tantilov for testing, review and suggestions.

---

 drivers/net/e1000e/e1000.h   |    1 +
 drivers/net/e1000e/ethtool.c |    6 ++++--
 drivers/net/e1000e/netdev.c  |   41 ++++++++++++++++++++++++++++-------------
 drivers/net/e1000e/param.c   |   36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 15 deletions(-)
drivers/net/e1000e/e1000.h +1 -0
index f9a31c8..6378da7 100644
@@ -370,6 +370,7 @@ struct e1000_adapter {
 	struct work_struct print_hang_task;
 
 	bool idle_check;
+	int node; /* store the node to allocate memory on */
 };
 
 struct e1000_info {
drivers/net/e1000e/ethtool.c +4 -2
index 6355a1b..1f7fe31 100644
@@ -690,7 +690,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
 	rx_old = adapter->rx_ring;
 
 	err = -ENOMEM;
-	tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
+	tx_ring = kzalloc_node(sizeof(struct e1000_ring), GFP_KERNEL,
+			       adapter->node);
 	if (!tx_ring)
 		goto err_alloc_tx;
 	/*
@@ -700,7 +701,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
 	 */
 	memcpy(tx_ring, tx_old, sizeof(struct e1000_ring));
 
-	rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
+	rx_ring = kzalloc_node(sizeof(struct e1000_ring), GFP_KERNEL,
+			       adapter->node);
 	if (!rx_ring)
 		goto err_alloc_rx;
 	memcpy(rx_ring, rx_old, sizeof(struct e1000_ring));
drivers/net/e1000e/netdev.c +28 -13

104 lines not on this page · raw message

drivers/net/e1000e/param.c +36 -0
index 34aeec1..9351ab0 100644
@@ -28,6 +28,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/pci.h>
+#include <linux/nodemask.h>
 
 #include "e1000.h"
 
@@ -161,6 +162,17 @@ E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lea
 E1000_PARAM(CrcStripping, "Enable CRC Stripping, disable if your BMC needs " \
                           "the CRC");
 
+/* Enable node specific allocation of all data structures, typically
+ *  specific to routing setups, not generally useful.
+ *
+ *  Depends on: NUMA configuration
+ *
+ * Valid Range: -1 or 0 to (MAX_NUMNODES - 1)
+ *
+ * Default Value: -1 (disabled, default to kernel choice of node)
+ */
+E1000_PARAM(Node, "[ROUTING] Node to allocate memory on, default -1");
+
 struct e1000_option {
 	enum { enable_option, range_option, list_option } type;
 	const char *name;
@@ -477,4 +489,28 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 			}
 		}
 	}
+	{ /* configure node specific allocation */
+		static struct e1000_option opt = {
+			.type = range_option,
+			.name = "Node used to allocate memory",
+			.err  = "defaulting to -1 (disabled)",
+			.def  = -1,
+			.arg  = { .r = { .min = 0,
+					 .max = MAX_NUMNODES - 1 } }
+		};
+		int node = opt.def;
+
+		if (num_Node > bd) {
+			node = Node[bd];
+			e1000_validate_option((uint *)&node, &opt, adapter);
+		}
+
+		/* check sanity of the value */
+		if ((node != -1) && !node_online(node)) {
+			e_info("ignoring node set to invalid value %d\n", node);
+			node = opt.def;
+		}
+
+		adapter->node = node;
+	}
 }
maintainer
#1 lore raw

From: Jeff Kirsher <[email protected]>
Date: Wed, 22 Sep 2010 20:28:10 -0700

Quoted 6 lines

Although a module parameter is not the preferred way for in-tree modules, this problem is not solvable in ethtool without mod params because of needing the information at probe time to control early allocations of memory. Ideally there would even be a way to control the node where the memory of the netdev struct would be allocated also.

Sorry, no.

Various folks are working on infrastructure such that the Numa node of everything other than the netdev struct can be dynamically choosen.

I'm sure we can find a way to dynamically reallocate and re-attach the netdev structure as well.

#2 lore raw
Quoted 10 lines · David Miller

From: Jeff Kirsher <[email protected]>
Date: Wed, 22 Sep 2010 20:28:10 -0700

Quoted 6 lines

Although a module parameter is not the preferred way for in-tree modules, this problem is not solvable in ethtool without mod params because of needing the information at probe time to control early allocations of memory. Ideally there would even be a way to control the node where the memory of the netdev struct would be allocated also.

Quoted 7 lines

Sorry, no.

Various folks are working on infrastructure such that the Numa node of everything other than the netdev struct can be dynamically choosen.

I'm sure we can find a way to dynamically reallocate and re-attach the netdev structure as well.

okay, thanks for your comments, we can carry this patch out-of-tree.

Unfortunately as I said in the comments there is really no way around this *now* other than some fixed binding scheme, none of which are one size fits all, which is why I (reluctantly) supplied the module parameter patch.

I'm interested to hear more about the "various folks' infrastructure" plans, I'll do some research. I can definitely provide testing.

The big gains from this patch come in router set ups, or really anything with lots of small-ish packets. The cross node traffic *really* impacts I/O workloads, and when trying to tune a system for performance, the lack of being able to control where the hot path memory for an adapter is allocated can cause extremely difficult to diagnose performance problems.

We don't generally post numbers, but if it would help get this patch accepted I could run some "for example" numbers with my 12 port 1G e1000e routing setup, maybe
1) irqbalance only,
2) taskset modprobe/ifup, irq bind (basically everything you can do without the patch)
3) patch applied, with nodes set, irq bind

If that would be useful let me know, I don't want to waste yours or my time.

#3 lore raw
Quoted 23 lines · Jesse
Quoted 10 lines · David Miller

From: Jeff Kirsher <[email protected]>
Date: Wed, 22 Sep 2010 20:28:10 -0700

Quoted 6 lines

Although a module parameter is not the preferred way for in-tree modules, this problem is not solvable in ethtool without mod params because of needing the information at probe time to control early allocations of memory. Ideally there would even be a way to control the node where the memory of the netdev struct would be allocated also.

Quoted 7 lines

Sorry, no.

Various folks are working on infrastructure such that the Numa node of everything other than the netdev struct can be dynamically choosen.

I'm sure we can find a way to dynamically reallocate and re-attach the netdev structure as well.

okay, thanks for your comments, we can carry this patch out-of-tree.

Quoted 7 lines

Unfortunately as I said in the comments there is really no way around this *now* other than some fixed binding scheme, none of which are one size fits all, which is why I (reluctantly) supplied the module parameter patch.

I'm interested to hear more about the "various folks' infrastructure" plans, I'll do some research. I can definitely provide testing.

[...]

I think David may be referring to this:

http://article.gmane.org/gmane.linux.network/172386

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.