Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9190b3b3 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net_sched: accurate bytes/packets stats/rates



In commit 44b82883 (net_sched: pfifo_head_drop problem), we fixed
a problem with pfifo_head drops that incorrectly decreased
sch->bstats.bytes and sch->bstats.packets

Several qdiscs (CHOKe, SFQ, pfifo_head, ...) are able to drop a
previously enqueued packet, and bstats cannot be changed, so
bstats/rates are not accurate (over estimated)

This patch changes the qdisc_bstats updates to be done at dequeue() time
instead of enqueue() time. bstats counters no longer account for dropped
frames, and rates are more correct, since enqueue() bursts dont have
effect on dequeue() rate.

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b3053251
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -445,7 +445,6 @@ static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,
{
	__skb_queue_tail(list, skb);
	sch->qstats.backlog += qdisc_pkt_len(skb);
	qdisc_bstats_update(sch, skb);

	return NET_XMIT_SUCCESS;
}
@@ -460,8 +459,10 @@ static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch,
{
	struct sk_buff *skb = __skb_dequeue(list);

	if (likely(skb != NULL))
	if (likely(skb != NULL)) {
		sch->qstats.backlog -= qdisc_pkt_len(skb);
		qdisc_bstats_update(sch, skb);
	}

	return skb;
}
@@ -474,10 +475,11 @@ static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch)
static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch,
					      struct sk_buff_head *list)
{
	struct sk_buff *skb = __qdisc_dequeue_head(sch, list);
	struct sk_buff *skb = __skb_dequeue(list);

	if (likely(skb != NULL)) {
		unsigned int len = qdisc_pkt_len(skb);
		sch->qstats.backlog -= len;
		kfree_skb(skb);
		return len;
	}
+1 −2
Original line number Diff line number Diff line
@@ -390,7 +390,6 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
	ret = qdisc_enqueue(skb, cl->q);
	if (ret == NET_XMIT_SUCCESS) {
		sch->q.qlen++;
		qdisc_bstats_update(sch, skb);
		cbq_mark_toplevel(q, cl);
		if (!cl->next_alive)
			cbq_activate_class(cl);
@@ -649,7 +648,6 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child)
		ret = qdisc_enqueue(skb, cl->q);
		if (ret == NET_XMIT_SUCCESS) {
			sch->q.qlen++;
			qdisc_bstats_update(sch, skb);
			if (!cl->next_alive)
				cbq_activate_class(cl);
			return 0;
@@ -971,6 +969,7 @@ cbq_dequeue(struct Qdisc *sch)

		skb = cbq_dequeue_1(sch);
		if (skb) {
			qdisc_bstats_update(sch, skb);
			sch->q.qlen--;
			sch->flags &= ~TCQ_F_THROTTLED;
			return skb;
+1 −1
Original line number Diff line number Diff line
@@ -376,7 +376,6 @@ static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch)
	}

	bstats_update(&cl->bstats, skb);
	qdisc_bstats_update(sch, skb);

	sch->q.qlen++;
	return err;
@@ -403,6 +402,7 @@ static struct sk_buff *drr_dequeue(struct Qdisc *sch)
			skb = qdisc_dequeue_peeked(cl->qdisc);
			if (cl->qdisc->q.qlen == 0)
				list_del(&cl->alist);
			qdisc_bstats_update(sch, skb);
			sch->q.qlen--;
			return skb;
		}
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,6 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch)
		return err;
	}

	qdisc_bstats_update(sch, skb);
	sch->q.qlen++;

	return NET_XMIT_SUCCESS;
@@ -283,6 +282,7 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
	if (skb == NULL)
		return NULL;

	qdisc_bstats_update(sch, skb);
	sch->q.qlen--;

	index = skb->tc_index & (p->indices - 1);
+1 −4
Original line number Diff line number Diff line
@@ -46,17 +46,14 @@ static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch)

static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc* sch)
{
	struct sk_buff *skb_head;
	struct fifo_sched_data *q = qdisc_priv(sch);

	if (likely(skb_queue_len(&sch->q) < q->limit))
		return qdisc_enqueue_tail(skb, sch);

	/* queue full, remove one skb to fulfill the limit */
	skb_head = qdisc_dequeue_head(sch);
	__qdisc_queue_drop_head(sch, &sch->q);
	sch->qstats.drops++;
	kfree_skb(skb_head);

	qdisc_enqueue_tail(skb, sch);

	return NET_XMIT_CN;
Loading