All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: rps: add the shortcut for one rps_cpus
@ 2010-09-04  9:12 Changli Gao
  2010-09-04 11:01 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-09-04  9:12 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Changli Gao

When there is only one rps_cpus, skb_get_rxhash() can be eliminated.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 net/core/dev.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index d8c43e7..2bf740c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2345,7 +2345,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
 		       struct rps_dev_flow **rflowp)
 {
 	struct netdev_rx_queue *rxqueue;
-	struct rps_map *map;
+	struct rps_map *map = NULL;
 	struct rps_dev_flow_table *flow_table;
 	struct rps_sock_flow_table *sock_flow_table;
 	int cpu = -1;
@@ -2363,8 +2363,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
 	} else
 		rxqueue = dev->_rx;
 
-	if (!rxqueue->rps_map && !rxqueue->rps_flow_table)
+	if (rxqueue->rps_map) {
+		map = rcu_dereference(rxqueue->rps_map);
+		if (map && map->len == 1) {
+			tcpu = map->cpus[0];
+			if (cpu_online(tcpu))
+				cpu = tcpu;
+			goto done;
+		}
+	} else if (!rxqueue->rps_flow_table) {
 		goto done;
+	}
 
 	skb_reset_network_header(skb);
 	if (!skb_get_rxhash(skb))
@@ -2409,7 +2418,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
 		}
 	}
 
-	map = rcu_dereference(rxqueue->rps_map);
 	if (map) {
 		tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
 

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

* Re: [PATCH] net: rps: add the shortcut for one rps_cpus
  2010-09-04  9:12 [PATCH] net: rps: add the shortcut for one rps_cpus Changli Gao
@ 2010-09-04 11:01 ` Eric Dumazet
  2010-09-04 12:18   ` Changli Gao
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-09-04 11:01 UTC (permalink / raw)
  To: Changli Gao; +Cc: David S. Miller, netdev

Le samedi 04 septembre 2010 à 17:12 +0800, Changli Gao a écrit :
> When there is only one rps_cpus, skb_get_rxhash() can be eliminated.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
>  net/core/dev.c |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d8c43e7..2bf740c 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2345,7 +2345,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
>  		       struct rps_dev_flow **rflowp)
>  {
>  	struct netdev_rx_queue *rxqueue;
> -	struct rps_map *map;
> +	struct rps_map *map = NULL;
>  	struct rps_dev_flow_table *flow_table;
>  	struct rps_sock_flow_table *sock_flow_table;
>  	int cpu = -1;
> @@ -2363,8 +2363,17 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
>  	} else
>  		rxqueue = dev->_rx;
>  
> -	if (!rxqueue->rps_map && !rxqueue->rps_flow_table)
> +	if (rxqueue->rps_map) {
> +		map = rcu_dereference(rxqueue->rps_map);
> +		if (map && map->len == 1) {
> +			tcpu = map->cpus[0];
> +			if (cpu_online(tcpu))
> +				cpu = tcpu;
> +			goto done;
> +		}
> +	} else if (!rxqueue->rps_flow_table) {
>  		goto done;
> +	}
>  
>  	skb_reset_network_header(skb);
>  	if (!skb_get_rxhash(skb))
> @@ -2409,7 +2418,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
>  		}
>  	}
>  
> -	map = rcu_dereference(rxqueue->rps_map);
>  	if (map) {
>  		tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];
>  
> --

You are 'optimizing' a very unusual case and slow down 99% of normal
uses.

Normal way to handle this, is to use irq affinity and deliver interrupts
directly to the target cpu. 




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

* Re: [PATCH] net: rps: add the shortcut for one rps_cpus
  2010-09-04 11:01 ` Eric Dumazet
@ 2010-09-04 12:18   ` Changli Gao
  2010-09-08 20:11     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-09-04 12:18 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, netdev

On Sat, Sep 4, 2010 at 7:01 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> You are 'optimizing' a very unusual case and slow down 99% of normal
> uses.
>
> Normal way to handle this, is to use irq affinity and deliver interrupts
> directly to the target cpu.
>
>

Some pseudo network devices may share the same interrupt, such as vlan
network devices. In this case, setting the IRQ affinity can't work.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

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

* Re: [PATCH] net: rps: add the shortcut for one rps_cpus
  2010-09-04 12:18   ` Changli Gao
@ 2010-09-08 20:11     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-09-08 20:11 UTC (permalink / raw)
  To: xiaosuo; +Cc: eric.dumazet, netdev

From: Changli Gao <xiaosuo@gmail.com>
Date: Sat, 4 Sep 2010 20:18:20 +0800

> On Sat, Sep 4, 2010 at 7:01 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> You are 'optimizing' a very unusual case and slow down 99% of normal
>> uses.
>>
>> Normal way to handle this, is to use irq affinity and deliver interrupts
>> directly to the target cpu.
>>
>>
> 
> Some pseudo network devices may share the same interrupt, such as vlan
> network devices. In this case, setting the IRQ affinity can't work.

I'm fine with this patch being in net-next-2.6 for now, so I've
applied it, thanks.

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

end of thread, other threads:[~2010-09-08 20:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-04  9:12 [PATCH] net: rps: add the shortcut for one rps_cpus Changli Gao
2010-09-04 11:01 ` Eric Dumazet
2010-09-04 12:18   ` Changli Gao
2010-09-08 20:11     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.