Patchwork [net-next,1/2] sch_sfq: store flow_keys in skb->cb[]

login
register
mail settings
Submitter Eric Dumazet
Date Dec. 16, 2011, 5:39 a.m.
Message ID <1324013979.2562.31.camel@edumazet-laptop>
Download mbox | patch
Permalink /patch/131781/
State Deferred
Delegated to: David Miller
Headers show

Comments

Eric Dumazet - Dec. 16, 2011, 5:39 a.m.
Instead of using automatic flow_keys variable in sfq_hash(), use storage
from skb->cb[] so that we can reuse it later if we want to rehash queues
when perturbation timer fires.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 net/sched/sch_sfq.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Dec. 16, 2011, 6:54 p.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 16 Dec 2011 06:39:39 +0100

> Instead of using automatic flow_keys variable in sfq_hash(), use storage
> from skb->cb[] so that we can reuse it later if we want to rehash queues
> when perturbation timer fires.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Where is "2/2"?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet - Dec. 16, 2011, 7:31 p.m.
Le vendredi 16 décembre 2011 à 13:54 -0500, David Miller a écrit :
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Fri, 16 Dec 2011 06:39:39 +0100
> 
> > Instead of using automatic flow_keys variable in sfq_hash(), use storage
> > from skb->cb[] so that we can reuse it later if we want to rehash queues
> > when perturbation timer fires.
> > 
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> 
> Where is "2/2"?

I got distracted by other stuff today, will finish later.

You can delete this one, I'll submit a proper serie when done.

Thanks !


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 46d0d77..72bccd0 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -136,16 +136,31 @@  static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index
 	return &q->dep[val - SFQ_SLOTS];
 }
 
+/*
+ * In order to be able to quickly rehash our queue when timer changes
+ * q->perturbation, we store flow_keys in skb->cb[]
+ */
+struct sfq_skb_cb {
+	struct flow_keys	keys;
+};
+
+static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb)
+{
+	BUILD_BUG_ON(sizeof(skb->cb) <
+		sizeof(struct qdisc_skb_cb) + sizeof(struct sfq_skb_cb));
+	return (struct sfq_skb_cb *)qdisc_skb_cb(skb)->data;
+}
+
 static unsigned int sfq_hash(const struct sfq_sched_data *q,
-			     const struct sk_buff *skb)
+			     struct sk_buff *skb)
 {
-	struct flow_keys keys;
+	struct flow_keys *keys = &sfq_skb_cb(skb)->keys;
 	unsigned int hash;
 
-	skb_flow_dissect(skb, &keys);
-	hash = jhash_3words((__force u32)keys.dst,
-			    (__force u32)keys.src ^ keys.ip_proto,
-			    (__force u32)keys.ports, q->perturbation);
+	skb_flow_dissect(skb, keys);
+	hash = jhash_3words((__force u32)keys->dst,
+			    (__force u32)keys->src ^ keys->ip_proto,
+			    (__force u32)keys->ports, q->perturbation);
 	return hash & (q->divisor - 1);
 }