Skip to contentSkip to conversation

fq_codel: Avoid regenerating skb flow hash unless necessary

PATCH Applied Andrew Collins 4 participants 5 messages Jan 18, 2017 – Jan 20, 2017

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

PATCH 1/1 fq_codel: Avoid regenerating skb flow hash unless necessary

The fq_codel qdisc currently always regenerates the skb flow hash. This wastes some cycles and prevents flow seperation in cases where the traffic has been encrypted and can no longer be understood by the flow dissector.

Change it to use the prexisting flow hash if one exists, and only regenerate if necessary.

---
 net/sched/sch_fq_codel.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/sched/sch_fq_codel.c +1 -5
index a5ea0e9..2f50e4c 100644
@@ -57,7 +57,6 @@ struct fq_codel_sched_data {
 	struct fq_codel_flow *flows;	/* Flows table [flows_cnt] */
 	u32		*backlogs;	/* backlog table [flows_cnt] */
 	u32		flows_cnt;	/* number of flows */
-	u32		perturbation;	/* hash perturbation */
 	u32		quantum;	/* psched_mtu(qdisc_dev(sch)); */
 	u32		drop_batch_size;
 	u32		memory_limit;
@@ -75,9 +74,7 @@ struct fq_codel_sched_data {
 static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q,
 				  struct sk_buff *skb)
 {
-	u32 hash = skb_get_hash_perturb(skb, q->perturbation);
-
-	return reciprocal_scale(hash, q->flows_cnt);
+	return reciprocal_scale(skb_get_hash(skb), q->flows_cnt);
 }
 
 static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch,
@@ -482,7 +479,6 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
 	q->memory_limit = 32 << 20; /* 32 MBytes */
 	q->drop_batch_size = 64;
 	q->quantum = psched_mtu(qdisc_dev(sch));
-	q->perturbation = prandom_u32();
 	INIT_LIST_HEAD(&q->new_flows);
 	INIT_LIST_HEAD(&q->old_flows);
 	codel_params_init(&q->cparams);
Signature · 1 line
2.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrew Collins

The fq_codel qdisc currently always regenerates the skb flow hash. This wastes some cycles and prevents flow seperation in cases where the traffic has been encrypted and can no longer be understood by the flow dissector.

Change it to use the prexisting flow hash if one exists, and only regenerate if necessary.

---

Thanks !

maintainer Applied
#2 lore raw
In reply to Andrew Collins

From: Andrew Collins <[email protected]>
Date: Wed, 18 Jan 2017 14:04:28 -0700

Quoted 9 lines

The fq_codel qdisc currently always regenerates the skb flow hash. This wastes some cycles and prevents flow seperation in cases where the traffic has been encrypted and can no longer be understood by the flow dissector.

Change it to use the prexisting flow hash if one exists, and only regenerate if necessary.

Applied, thanks.

#3 lore raw
In reply to Andrew Collins
Quoted 26 lines · Andrew Collins

The fq_codel qdisc currently always regenerates the skb flow hash. This wastes some cycles and prevents flow seperation in cases where the traffic has been encrypted and can no longer be understood by the flow dissector.

Change it to use the prexisting flow hash if one exists, and only regenerate if necessary.

---
 net/sched/sch_fq_codel.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/sched/sch_fq_codel.c +0 -1
index a5ea0e9..2f50e4c 100644
@@ -57,7 +57,6 @@ struct fq_codel_sched_data {
        struct fq_codel_flow *flows;    /* Flows table [flows_cnt] */
        u32             *backlogs;      /* backlog table [flows_cnt] */
        u32             flows_cnt;      /* number of flows */
-       u32             perturbation;   /* hash perturbation */
        u32             quantum;        /* psched_mtu(qdisc_dev(sch)); */
        u32             drop_batch_size;
        u32             memory_limit;

net/sched/sch_fq_codel.c struct fq_codel_sched_data { · line 77

Quoted 7 lines
net/sched/sch_fq_codel.c +1 -3
@@ -75,9 +74,7 @@ struct fq_codel_sched_data {
 static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q,
                                  struct sk_buff *skb)
 {
-       u32 hash = skb_get_hash_perturb(skb, q->perturbation);
-
-       return reciprocal_scale(hash, q->flows_cnt);
+       return reciprocal_scale(skb_get_hash(skb), q->flows_cnt);

So the perturbing of the hash is no longer needed for fq_codel?

Quoted 14 lines
net/sched/sch_fq_codel.c +0 -2
 }
 
 static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch,
@@ -482,7 +479,6 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
        q->memory_limit = 32 << 20; /* 32 MBytes */
        q->drop_batch_size = 64;
        q->quantum = psched_mtu(qdisc_dev(sch));
-       q->perturbation = prandom_u32();
        INIT_LIST_HEAD(&q->new_flows);
        INIT_LIST_HEAD(&q->old_flows);
        codel_params_init(&q->cparams);
--

2.9.3

#4 lore raw
Quoted 1 line · Tom Herbert

So the perturbing of the hash is no longer needed for fq_codel?

Right, we never implemented a timer to change the perturbation anyway.

Note that local TCP flows now implement their own hash change when needed.