Skip to contentSkip to conversation

cbq: remove only caller of qdisc->drop()

PATCH In review Florian Westphal 3 participants 4 messages Jun 6, 2016 – Jun 8, 2016

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

PATCH 1/1 cbq: remove only caller of qdisc->drop()

since initial revision of cbq in 2004 iproute2 never implemented support for TCA_CBQ_OVL_STRATEGY, which is what needs to be set to activate the class->drop() call (TC_CBQ_OVL_DROP strategy must be set by userspace).

So lets remove this. We can even do this in a backwards compatible way by switching ovl_drop to perform a dequeue+drop on the leaf.

A followup commit can then remove all .drop qdisc methods since this was the only caller.

---
On a related note, iproute2 doesn't support the TCA_CBQ_POLICE attribute either. If we'd remove that too we could then get rid of __parent and reshape_fail in struct Qdisc.

However, in TCA_CBQ_POLICE case there is no way to replace the functionality, i.e. we'd have to -EOPNOTSUPP or ignore TCA_CBQ_POLICE if some other non-iproute2 tool presents it to us.

AFAICS TCA_CBQ_POLICE doesn't work all that well even if userspace would set it, one needs to:

add a class
attach a qdisc to the class (default pfifo doesn't work as

      q->handle is 0 and cbq_set_police() is a no-op in this case)

re-'add' the same class (tc class change ...) again

user must also specifiy a defmap (e.g. 'split 1:0 defmap 3f'), since this 'police' feature relies on its presence
the added qdisc (or the leaves) must be one of bfifo, pfifo, tbf or netem as only these implement qdisc_reshape_fail() call.

If all of these conditions are met, then instead of drop the leaf qdiscs mentioned above would attempt to re-enqueue the skb in the cbq TC_PRIO_BESTEFFORT class if their limit is reached.

I think it would be safe to just ignore TCA_CBQ_POLICE and change the qdiscs to drop right away.

Does anyone have a reason to leave this in the tree? Thanks!

net/sched/sch_cbq.c +8 -3
index baafddf..df79791 100644
@@ -542,9 +542,14 @@ static void cbq_ovl_lowprio(struct cbq_class *cl)
 
 static void cbq_ovl_drop(struct cbq_class *cl)
 {
-	if (cl->q->ops->drop)
-		if (cl->q->ops->drop(cl->q))
-			cl->qdisc->q.qlen--;
+	struct sk_buff *skb = cl->q->ops->dequeue(cl->q);
+
+	if (skb) {
+		cl->deficit -= qdisc_pkt_len(skb);
+		cl->qdisc->q.qlen--;
+		qdisc_drop(skb, cl->qdisc);
+	}
+
 	cl->xstats.overactions++;
 	cbq_ovl_classic(cl);
 }
Signature · 1 line
2.7.3
#1 lore raw
Quoted 55 lines · Florian Westphal

since initial revision of cbq in 2004 iproute2 never implemented support for TCA_CBQ_OVL_STRATEGY, which is what needs to be set to activate the class->drop() call (TC_CBQ_OVL_DROP strategy must be set by userspace).

So lets remove this. We can even do this in a backwards compatible way by switching ovl_drop to perform a dequeue+drop on the leaf.

A followup commit can then remove all .drop qdisc methods since this was the only caller.

---
On a related note, iproute2 doesn't support the TCA_CBQ_POLICE attribute either. If we'd remove that too we could then get rid of __parent and reshape_fail in struct Qdisc.

However, in TCA_CBQ_POLICE case there is no way to replace the functionality, i.e. we'd have to -EOPNOTSUPP or ignore TCA_CBQ_POLICE if some other non-iproute2 tool presents it to us.

AFAICS TCA_CBQ_POLICE doesn't work all that well even if userspace would set it, one needs to:

add a class
attach a qdisc to the class (default pfifo doesn't work as

      q->handle is 0 and cbq_set_police() is a no-op in this case)

re-'add' the same class (tc class change ...) again

user must also specifiy a defmap (e.g. 'split 1:0 defmap 3f'), since this 'police' feature relies on its presence
the added qdisc (or the leaves) must be one of bfifo, pfifo, tbf or netem as only these implement qdisc_reshape_fail() call.

If all of these conditions are met, then instead of drop the leaf qdiscs mentioned above would attempt to re-enqueue the skb in the cbq TC_PRIO_BESTEFFORT class if their limit is reached.

I think it would be safe to just ignore TCA_CBQ_POLICE and change the qdiscs to drop right away.

Does anyone have a reason to leave this in the tree? Thanks!

net/sched/sch_cbq.c +1 -3
index baafddf..df79791 100644
@@ -542,9 +542,14 @@ static void cbq_ovl_lowprio(struct cbq_class *cl)
 
 static void cbq_ovl_drop(struct cbq_class *cl)
 {
-	if (cl->q->ops->drop)
-		if (cl->q->ops->drop(cl->q))
-			cl->qdisc->q.qlen--;
+	struct sk_buff *skb = cl->q->ops->dequeue(cl->q);

net/sched/sch_cbq.c static void cbq_ovl_lowprio(struct cbq_class *cl) · line 555

Quoted 10 lines
net/sched/sch_cbq.c +7 -0
+
+	if (skb) {
+		cl->deficit -= qdisc_pkt_len(skb);
+		cl->qdisc->q.qlen--;
+		qdisc_drop(skb, cl->qdisc);
+	}
+
 	cl->xstats.overactions++;
 	cbq_ovl_classic(cl);
 }

A drop() is not equivalent to a dequeue() followed by qdisc_drop() for statistics.

dequeue() will update stats of _sent_ packets/bytes, while drop() should not.

#2 lore raw
Quoted 20 lines · Eric Dumazet
Quoted 6 lines

static void cbq_ovl_drop(struct cbq_class *cl)
{

net/sched/sch_cbq.c +1 -3
-	if (cl->q->ops->drop)
-		if (cl->q->ops->drop(cl->q))
-			cl->qdisc->q.qlen--;
+	struct sk_buff *skb = cl->q->ops->dequeue(cl->q);

net/sched/sch_cbq.c static void cbq_ovl_lowprio(struct cbq_class *cl) · line 555

Quoted 10 lines
net/sched/sch_cbq.c +7 -0
+
+	if (skb) {
+		cl->deficit -= qdisc_pkt_len(skb);
+		cl->qdisc->q.qlen--;
+		qdisc_drop(skb, cl->qdisc);
+	}
+
 	cl->xstats.overactions++;
 	cbq_ovl_classic(cl);
 }

A drop() is not equivalent to a dequeue() followed by qdisc_drop() for statistics.

Quoted 2 lines

dequeue() will update stats of _sent_ packets/bytes, while drop() should not.

Well, I could send patch to just remove cbq_ovl_drop completely, you can't configure this facility with iproute2.

You are right of course, but is it really worth to have this?

Not calling cl->q->ops->drop() in cbq would allow removal of ~300 LOC in qdiscs...

maintainer
#3 lore raw
In reply to Florian Westphal

From: Florian Westphal <[email protected]>
Date: Mon, 6 Jun 2016 23:20:27 +0200

Quoted 5 lines

since initial revision of cbq in 2004 iproute2 never implemented support for TCA_CBQ_OVL_STRATEGY, which is what needs to be set to activate the class->drop() call (TC_CBQ_OVL_DROP strategy must be set by userspace).

Quoted 7 lines

So lets remove this. We can even do this in a backwards compatible way by switching ovl_drop to perform a dequeue+drop on the leaf.

A followup commit can then remove all .drop qdisc methods since this was the only caller.

I don't see anything, anywhere, using TCA_CBQ_OVL_STRATEGY nor the various strategy type values.

iproute2 seems to notice the attribute in dumps, but doesn't do anything with it other than verify that it's size meets some minimum.

It seems really safe to kill this thing off, flag an error if someone tries to set the attribute, and therefore kill off all of the non-default cbq_ovl_*() functions.

Quoted 4 lines

I think it would be safe to just ignore TCA_CBQ_POLICE and change the qdiscs to drop right away.

Does anyone have a reason to leave this in the tree? Thanks!

The TCA_CBQ_POLICE situation looks similar to the TCA_CBQ_OVL_STRATEGY one to me.

Thanks.