All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection
@ 2014-03-21  0:09 Tom Herbert
  2014-03-21  1:31 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Herbert @ 2014-03-21  0:09 UTC (permalink / raw)
  To: davem, netdev

__skb_get_hash tries to get the skb->hash from a connected socket
associated with an skb. __skb_tx_hash and get_xps_queue just call
skb_get_hash().

Signed-off-by: Tom Herbert <therbert@google.com>
---
 include/linux/netdevice.h |  2 +-
 include/linux/skbuff.h    |  2 +-
 net/core/flow_dissector.c | 22 +++++++++-------------
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4b6d12c..a1fa2e4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2481,7 +2481,7 @@ static inline int netif_set_xps_queue(struct net_device *dev,
  * as a distribution range limit for the returned value.
  */
 static inline u16 skb_tx_hash(const struct net_device *dev,
-			      const struct sk_buff *skb)
+			      struct sk_buff *skb)
 {
 	return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
 }
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index aa2c22c..f392b74 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2863,7 +2863,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
 	return skb->queue_mapping != 0;
 }
 
-u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
+u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
 		  unsigned int num_tx_queues);
 
 static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 107ed12..432d35a 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -212,6 +212,12 @@ void __skb_get_hash(struct sk_buff *skb)
 	struct flow_keys keys;
 	u32 hash;
 
+	if (skb->sk && skb->sk->sk_hash) {
+		skb->hash = skb->sk->sk_hash;
+		skb->l4_hash = 1;
+		return;
+	}
+
 	if (!skb_flow_dissect(skb, &keys))
 		return;
 
@@ -240,7 +246,7 @@ EXPORT_SYMBOL(__skb_get_hash);
  * Returns a Tx hash based on the given packet descriptor a Tx queues' number
  * to be used as a distribution range.
  */
-u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
+u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
 		  unsigned int num_tx_queues)
 {
 	u32 hash;
@@ -260,11 +266,7 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
 		qcount = dev->tc_to_txq[tc].count;
 	}
 
-	if (skb->sk && skb->sk->sk_hash)
-		hash = skb->sk->sk_hash;
-	else
-		hash = (__force u16) skb->protocol;
-	hash = __flow_hash_1word(hash);
+	hash = __flow_hash_1word(skb_get_hash(skb));
 
 	return (u16) (((u64) hash * qcount) >> 32) + qoffset;
 }
@@ -339,13 +341,7 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
 			if (map->len == 1)
 				queue_index = map->queues[0];
 			else {
-				u32 hash;
-				if (skb->sk && skb->sk->sk_hash)
-					hash = skb->sk->sk_hash;
-				else
-					hash = (__force u16) skb->protocol ^
-					    skb->hash;
-				hash = __flow_hash_1word(hash);
+				u32 hash = __flow_hash_1word(skb_get_hash(skb));
 				queue_index = map->queues[
 				    ((u64)hash * map->len) >> 32];
 			}
-- 
1.9.1.423.g4596e3a

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

* Re: [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection
  2014-03-21  0:09 [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection Tom Herbert
@ 2014-03-21  1:31 ` Eric Dumazet
  2014-03-21  1:37   ` Eric Dumazet
  2014-03-21 19:24   ` Tom Herbert
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2014-03-21  1:31 UTC (permalink / raw)
  To: Tom Herbert; +Cc: davem, netdev

On Thu, 2014-03-20 at 17:09 -0700, Tom Herbert wrote:
> __skb_get_hash tries to get the skb->hash from a connected socket
> associated with an skb. __skb_tx_hash and get_xps_queue just call
> skb_get_hash().
> 
> Signed-off-by: Tom Herbert <therbert@google.com>
> ---
>  include/linux/netdevice.h |  2 +-
>  include/linux/skbuff.h    |  2 +-
>  net/core/flow_dissector.c | 22 +++++++++-------------
>  3 files changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 4b6d12c..a1fa2e4 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2481,7 +2481,7 @@ static inline int netif_set_xps_queue(struct net_device *dev,
>   * as a distribution range limit for the returned value.
>   */
>  static inline u16 skb_tx_hash(const struct net_device *dev,
> -			      const struct sk_buff *skb)
> +			      struct sk_buff *skb)
>  {
>  	return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
>  }
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index aa2c22c..f392b74 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2863,7 +2863,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
>  	return skb->queue_mapping != 0;
>  }
>  
> -u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
> +u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
>  		  unsigned int num_tx_queues);
>  
>  static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 107ed12..432d35a 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -212,6 +212,12 @@ void __skb_get_hash(struct sk_buff *skb)
>  	struct flow_keys keys;
>  	u32 hash;
>  
> +	if (skb->sk && skb->sk->sk_hash) {
> +		skb->hash = skb->sk->sk_hash;
> +		skb->l4_hash = 1;
> +		return;
> +	}

Wouldn't it be faster to simply set skb->hash in providers (TCP, UDP),
to that we do not add this test here ?

After packet has been a while in a qdisc, access to skb->sk_hash will
likely trigger a cache line miss.

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

* Re: [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection
  2014-03-21  1:31 ` Eric Dumazet
@ 2014-03-21  1:37   ` Eric Dumazet
  2014-03-21 19:24   ` Tom Herbert
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2014-03-21  1:37 UTC (permalink / raw)
  To: Tom Herbert; +Cc: davem, netdev

On Thu, 2014-03-20 at 18:31 -0700, Eric Dumazet wrote:

> Wouldn't it be faster to simply set skb->hash in providers (TCP, UDP),
> to that we do not add this test here ?
> 
> After packet has been a while in a qdisc, access to skb->sk_hash will
> likely trigger a cache line miss.

I meant access to skb->sk->sk_hash will likely trigger a cache line
miss.

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

* Re: [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection
  2014-03-21  1:31 ` Eric Dumazet
  2014-03-21  1:37   ` Eric Dumazet
@ 2014-03-21 19:24   ` Tom Herbert
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Herbert @ 2014-03-21 19:24 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, Linux Netdev List

On Thu, Mar 20, 2014 at 6:31 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Thu, 2014-03-20 at 17:09 -0700, Tom Herbert wrote:
>> __skb_get_hash tries to get the skb->hash from a connected socket
>> associated with an skb. __skb_tx_hash and get_xps_queue just call
>> skb_get_hash().
>>
>> Signed-off-by: Tom Herbert <therbert@google.com>
>> ---
>>  include/linux/netdevice.h |  2 +-
>>  include/linux/skbuff.h    |  2 +-
>>  net/core/flow_dissector.c | 22 +++++++++-------------
>>  3 files changed, 11 insertions(+), 15 deletions(-)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 4b6d12c..a1fa2e4 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -2481,7 +2481,7 @@ static inline int netif_set_xps_queue(struct net_device *dev,
>>   * as a distribution range limit for the returned value.
>>   */
>>  static inline u16 skb_tx_hash(const struct net_device *dev,
>> -                           const struct sk_buff *skb)
>> +                           struct sk_buff *skb)
>>  {
>>       return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
>>  }
>> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
>> index aa2c22c..f392b74 100644
>> --- a/include/linux/skbuff.h
>> +++ b/include/linux/skbuff.h
>> @@ -2863,7 +2863,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
>>       return skb->queue_mapping != 0;
>>  }
>>
>> -u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
>> +u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
>>                 unsigned int num_tx_queues);
>>
>>  static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
>> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
>> index 107ed12..432d35a 100644
>> --- a/net/core/flow_dissector.c
>> +++ b/net/core/flow_dissector.c
>> @@ -212,6 +212,12 @@ void __skb_get_hash(struct sk_buff *skb)
>>       struct flow_keys keys;
>>       u32 hash;
>>
>> +     if (skb->sk && skb->sk->sk_hash) {
>> +             skb->hash = skb->sk->sk_hash;
>> +             skb->l4_hash = 1;
>> +             return;
>> +     }
>
> Wouldn't it be faster to simply set skb->hash in providers (TCP, UDP),
> to that we do not add this test here ?
>
Excellent idea. We should be able to eliminate all occurrences of "if
(skb->sk && skb->sk->sk_hash)" in the stack!

> After packet has been a while in a qdisc, access to skb->sk_hash will
> likely trigger a cache line miss.
>
>
>

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

end of thread, other threads:[~2014-03-21 19:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-21  0:09 [PATCH net-next 2/4] net: use skb_get_hash in tx queue selection Tom Herbert
2014-03-21  1:31 ` Eric Dumazet
2014-03-21  1:37   ` Eric Dumazet
2014-03-21 19:24   ` Tom Herbert

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.