Skip to contentSkip to conversation

net_sched: restore "mpu xxx" handling

PATCH In review Kirill Tkhai 2 participants 3 messages Jul 29, 2015

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

PATCH 1/1 net_sched: restore "mpu xxx" handling

commit 56b765b79 ("htb: improved accuracy at high rates") broke the "mpu xxx" handling.

This patch restores the "mpu xxx" handling for htb:

# tc class add dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 0
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 0.156/1.881/2.454/0.175 ms, ipg/ewma 1.908/1.925 ms
# tc class change dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 1000
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 15.352/22.229/38.646/2.212 ms, pipe 3, ipg/ewma 15.999/22.609 ms
CC Jesper Dangaard Brouer <[email protected]>
CC Eric Dumazet <[email protected]>
CC David S. Miller <[email protected]>
---
 include/net/sch_generic.h |    1 +
 net/sched/sch_htb.c       |   10 ++++++++++
 2 files changed, 11 insertions(+)
include/net/sch_generic.h +1 -0
index 2eab08c..0add26a 100644
@@ -756,6 +756,7 @@ struct psched_ratecfg {
 	u16	overhead;
 	u8	linklayer;
 	u8	shift;
+	u32	mpu;
 };
 
 static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
net/sched/sch_htb.c +10 -0
index f1acb0f..7b9f283 100644
@@ -608,6 +608,9 @@ static inline void htb_accnt_tokens(struct htb_class *cl, int bytes, s64 diff)
 {
 	s64 toks = diff + cl->tokens;
 
+	if (bytes < cl->rate.mpu)
+		bytes = cl->rate.mpu;
+
 	if (toks > cl->buffer)
 		toks = cl->buffer;
 	toks -= (s64) psched_l2t_ns(&cl->rate, bytes);
@@ -621,6 +624,9 @@ static inline void htb_accnt_ctokens(struct htb_class *cl, int bytes, s64 diff)
 {
 	s64 toks = diff + cl->ctokens;
 
+	if (bytes < cl->ceil.mpu)
+		bytes = cl->ceil.mpu;
+
 	if (toks > cl->cbuffer)
 		toks = cl->cbuffer;
 	toks -= (s64) psched_l2t_ns(&cl->ceil, bytes);
@@ -1112,8 +1118,10 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
 	memset(&opt, 0, sizeof(opt));
 
 	psched_ratecfg_getrate(&opt.rate, &cl->rate);
+	opt.rate.mpu = cl->rate.mpu;
 	opt.buffer = PSCHED_NS2TICKS(cl->buffer);
 	psched_ratecfg_getrate(&opt.ceil, &cl->ceil);
+	opt.ceil.mpu = cl->ceil.mpu;
 	opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
 	opt.quantum = cl->quantum;
 	opt.prio = cl->prio;
@@ -1484,6 +1492,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 
 	psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
 	psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
+	cl->rate.mpu = hopt->rate.mpu;
+	cl->ceil.mpu = hopt->ceil.mpu;
 
 	/* it used to be a nasty bug here, we have to check that node
 	 * is really leaf before changing cl->un.leaf !
#1 lore raw
Quoted 5 lines · Kirill Tkhai

commit 56b765b79 ("htb: improved accuracy at high rates") broke the "mpu xxx" handling.

This patch restores the "mpu xxx" handling for htb:

Quoted 7 lines
# tc class add dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 0
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 0.156/1.881/2.454/0.175 ms, ipg/ewma 1.908/1.925 ms
# tc class change dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 1000
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 15.352/22.229/38.646/2.212 ms, pipe 3, ipg/ewma 15.999/22.609 ms

Note this mpu option was completely broken a long time ago with GSO / TSO anyway.

Note sure we really want it in this state ?

What is your use case ?

In any case, correct fix would be in psched_l2t_ns(), otherwise you fix htb but not the other qdisc (tbf for that matter)

#2 lore raw
Quoted 14 lines · Eric Dumazet
Quoted 5 lines · Kirill Tkhai

commit 56b765b79 ("htb: improved accuracy at high rates") broke the "mpu xxx" handling.

This patch restores the "mpu xxx" handling for htb:

Quoted 7 lines
# tc class add dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 0
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 0.156/1.881/2.454/0.175 ms, ipg/ewma 1.908/1.925 ms
# tc class change dev eth0 classid 1:2 parent 1: htb rate 1mbit mpu 1000
# ping -f -c 1000 10.30.22.52
rtt min/avg/max/mdev = 15.352/22.229/38.646/2.212 ms, pipe 3, ipg/ewma 15.999/22.609 ms
Quoted 6 lines

Note this mpu option was completely broken a long time ago with GSO / TSO anyway.

Note sure we really want it in this state ?

What is your use case ?

It's a way to limit a number of small packets sent from inside container (virtual enviroment).

Its ethernet card is virtual and it's possible to control the things like TSO, and to turn it off.

We use that in 2.6.32. Now I'm working with 3.10 and found, that the interface has been changed. The patch is similar the functionality, which we had before commit 56b765b79.

Are there another alternatives?

Quoted 2 lines

In any case, correct fix would be in psched_l2t_ns(), otherwise you fix htb but not the other qdisc (tbf for that matter)

Sure, I'm agree.