netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rps: make distributing packets fairly among all the online CPUs default
@ 2010-03-23  6:24 Changli Gao
  2010-03-23  7:20 ` Eric Dumazet
  2010-03-23  7:27 ` Eric Dumazet
  0 siblings, 2 replies; 12+ messages in thread
From: Changli Gao @ 2010-03-23  6:24 UTC (permalink / raw)
  To: David S. Miller; +Cc: Tom Herbert, xiaosuo, netdev

make distributing packets fairly among all the online CPUs default.

Make distributing packets fairly among all the online CPUs default, then
users don't need any explicit configuration to get the benefit of RPS.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
net/core/dev.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index c0e2608..a4246f1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5234,6 +5234,24 @@ void netif_stacked_transfer_operstate(const struct net_device *rootdev,
 }
 EXPORT_SYMBOL(netif_stacked_transfer_operstate);
 
+static struct rps_map* alloc_rps_map(void)
+{
+	struct rps_map *map;
+	int i, cpu;
+
+	map = kzalloc(max_t(unsigned,
+			    RPS_MAP_SIZE(cpumask_weight(cpu_online_mask)),
+			    L1_CACHE_BYTES), GFP_KERNEL);
+	if (map == NULL)
+		return NULL;
+	i = 0;
+	for_each_online_cpu(cpu)
+		map->cpus[i++] = cpu;
+	map->len = i;
+
+	return map;
+}
+
 /**
  *	register_netdevice	- register a network device
  *	@dev: device to register
@@ -5282,7 +5300,13 @@ int register_netdevice(struct net_device *dev)
 			ret = -ENOMEM;
 			goto out;
 		}
-
+		dev->_rx->rps_map = alloc_rps_map();
+		if (dev->_rx->rps_map == NULL) {
+			kfree(dev->_rx);
+			dev->_rx = NULL;
+			ret = -ENOMEM;
+			goto out;
+		}
 		dev->_rx->first = dev->_rx;
 		atomic_set(&dev->_rx->count, 1);
 		dev->num_rx_queues = 1;
@@ -5688,8 +5712,12 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 	 * Set a pointer to first element in the array which holds the
 	 * reference count.
 	 */
-	for (i = 0; i < queue_count; i++)
+	for (i = 0; i < queue_count; i++) {
 		rx[i].first = rx;
+		rx[i].rps_map = alloc_rps_map();
+		if (rx[i].rps_map == NULL)
+			goto free_rx;
+	}
 
 	dev = PTR_ALIGN(p, NETDEV_ALIGN);
 	dev->padded = (char *)dev - (char *)p;
@@ -5723,6 +5751,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 	return dev;
 
 free_rx:
+	for (i = 0; i < queue_count; i++)
+		kfree(rx[i].rps_map);
 	kfree(rx);
 free_tx:
 	kfree(tx);



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-03-23 19:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23  6:24 [PATCH] rps: make distributing packets fairly among all the online CPUs default Changli Gao
2010-03-23  7:20 ` Eric Dumazet
2010-03-23  9:56   ` Changli Gao
2010-03-23 11:23     ` Eric Dumazet
2010-03-23 11:27       ` Changli Gao
2010-03-23  7:27 ` Eric Dumazet
2010-03-23 10:03   ` Changli Gao
2010-03-23 11:38     ` Eric Dumazet
2010-03-23 11:58       ` Changli Gao
2010-03-23 13:06         ` Eric Dumazet
2010-03-23 19:09           ` David Miller
2010-03-23 14:05     ` Andi Kleen

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).