Skip to contentSkip to conversation

mlx4_en: Setting RSS hash result to skb->rxhash field

PATCH In review Yevgeny Petrilin 4 participants 8 messages May 4, 2011 – May 5, 2011

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

PATCH 1/1 mlx4_en: Setting RSS hash result to skb->rxhash field

---
 drivers/net/mlx4/en_rx.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/mlx4/en_rx.c +3 -0
index 62dd21b..bb4d66a 100644
@@ -610,6 +610,8 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 					gro_skb->data_len = length;
 					gro_skb->truesize += length;
 					gro_skb->ip_summed = CHECKSUM_UNNECESSARY;
+					gro_skb->rxhash = be32_to_cpu(cqe->immed_rss_invalid) << 24;
+					skb_record_rx_queue(gro_skb, cq->ring);
 
 					if (priv->vlgrp && (cqe->vlan_my_qpn &
 							    cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK)))
@@ -643,6 +645,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 			goto next;
 		}
 
+		skb->rxhash = be32_to_cpu(cqe->immed_rss_invalid) << 24;
 		skb->ip_summed = ip_summed;
 		skb->protocol = eth_type_trans(skb, dev);
 		skb_record_rx_queue(skb, cq->ring);
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 10 lines · Yevgeny Petrilin
---
 drivers/net/mlx4/en_rx.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/mlx4/en_rx.c +0 -0
index 62dd21b..bb4d66a 100644

drivers/net/mlx4/en_rx.c int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud · line 614

Quoted 5 lines
drivers/net/mlx4/en_rx.c +2 -0
@@ -610,6 +610,8 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 					gro_skb->data_len = length;
 					gro_skb->truesize += length;
 					gro_skb->ip_summed = CHECKSUM_UNNECESSARY;
+					gro_skb->rxhash = be32_to_cpu(cqe->immed_rss_invalid) << 24;
+					skb_record_rx_queue(gro_skb, cq->ring);

An 8-bit hash is almost useless. It's entirely useless if you then shift it into the top bits of rxhash.

Ben.

Quoted 10 lines
drivers/net/mlx4/en_rx.c +1 -0
 					if (priv->vlgrp && (cqe->vlan_my_qpn &
 							    cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK)))
@@ -643,6 +645,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 			goto next;
 		}
 
+		skb->rxhash = be32_to_cpu(cqe->immed_rss_invalid) << 24;
 		skb->ip_summed = ip_summed;
 		skb->protocol = eth_type_trans(skb, dev);
 		skb_record_rx_queue(skb, cq->ring);
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw
Quoted 6 lines · Ben Hutchings
Quoted 5 lines · Yevgeny Petrilin
---
 drivers/net/mlx4/en_rx.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Quoted 14 lines

drivers/net/mlx4/en_rx.c int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud · line 614

Quoted 10 lines
drivers/net/mlx4/en_rx.c +2 -0
index 62dd21b..bb4d66a 100644
@@ -610,6 +610,8 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 					gro_skb->data_len = length;
 					gro_skb->truesize += length;
 					gro_skb->ip_summed = CHECKSUM_UNNECESSARY;
+					gro_skb->rxhash = be32_to_cpu(cqe->immed_rss_invalid) << 24;
+					skb_record_rx_queue(gro_skb, cq->ring);

An 8-bit hash is almost useless. It's entirely useless if you then shift it into the top bits of rxhash.

Agreed. This is very bad.

Yevgeny probably did this shift because get_rps_cpu() does :

tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];

(If rxhash is not a pure random u32 distribution, then high order bits are more important than low order bits)

#3 lore raw
Quoted 5 lines
Quoted 4 lines

An 8-bit hash is almost useless. It's entirely useless if you then shift it into the top bits of rxhash.

Quoted 9 lines

Agreed. This is very bad.

Yevgeny probably did this shift because get_rps_cpu() does :

tcpu = map->cpus[((u64) skb->rxhash * map->len) >> 32];

(If rxhash is not a pure random u32 distribution, then high order bits are more important than low order bits)

Eric, you are correct.
We do plan to enable full 32 bit hash for our devices.
Once it is done, we will naturally use the whole 32 bits.
In the meanwhile, even with this change we see improved performance when enabling RPS.

Thanks,
Yevgeny

#4 lore raw
Quoted 5 lines · Yevgeny Petrilin
Quoted 1 line

Eric, you are correct.
We do plan to enable full 32 bit hash for our devices.
Once it is done, we will naturally use the whole 32 bits.
In the meanwhile, even with this change we see improved performance when enabling RPS.

Hmm, thats strange because you have only 256 possible values for rxhash, and it's OK for maybe one hundred flows. (I am talking not of RPS but RFS here)

So your patch is a win only for small hosts, or particular workloads (did I say biased benchmarks ? ;) )

Really, we better use the linux/software full 32bit rxhash in this case, and wait for your 32bit full support.

#5 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 5 lines · Yevgeny Petrilin
Quoted 1 line

Eric, you are correct.
We do plan to enable full 32 bit hash for our devices.
Once it is done, we will naturally use the whole 32 bits.
In the meanwhile, even with this change we see improved performance when enabling RPS.

Hmm, thats strange because you have only 256 possible values for rxhash, and it's OK for maybe one hundred flows. (I am talking not of RPS but RFS here)

Quoted 7 lines

So your patch is a win only for small hosts, or particular workloads (did I say biased benchmarks ? ;) )

Really, we better use the linux/software full 32bit rxhash in this case, and wait for your 32bit full support.

BTW, before you submit another rxhash patch, please make sure ethtool support is included. An admin must be able to switch off hardware support :

ethtool -K eth0 rxhash off

#6 lore raw
Quoted 18 lines
Quoted 10 lines
Quoted 5 lines
Quoted 1 line

Eric, you are correct.
We do plan to enable full 32 bit hash for our devices.
Once it is done, we will naturally use the whole 32 bits.
In the meanwhile, even with this change we see improved performance when enabling RPS.

Hmm, thats strange because you have only 256 possible values for rxhash, and it's OK for maybe one hundred flows. (I am talking not of RPS but RFS here)

Quoted 7 lines

So your patch is a win only for small hosts, or particular workloads (did I say biased benchmarks ? ;) )

Really, we better use the linux/software full 32bit rxhash in this case, and wait for your 32bit full support.

Quoted 7 lines

BTW, before you submit another rxhash patch, please make sure ethtool support is included. An admin must be able to switch off hardware support :

ethtool -K eth0 rxhash off

Thanks for this input