From: Thomas Graf Date: Mon, 18 Jul 2005 20:30:53 +0000 (-0700) Subject: [PKT_SCHED]: Reduce branch mispredictions in pfifo_fast_dequeue X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=452f299da3253f65020143f743c2e207b752547b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PKT_SCHED]: Reduce branch mispredictions in pfifo_fast_dequeue The current call to __qdisc_dequeue_head leads to a branch misprediction for every loop iteration, the fact that the most common priority is 2 makes this even worse. This issue has been brought up by Eric Dumazet but unlike his solution which was to manually unroll the loop, this approach preserves the possibility to increase the number of bands at compile time. Signed-off-by: Thomas Graf Signed-off-by: David S. Miller --- diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 73e218e646ac..8edefd5d095d 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -331,11 +331,10 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc) int prio; struct sk_buff_head *list = qdisc_priv(qdisc); - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++, list++) { - struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list); - if (skb) { + for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) { + if (!skb_queue_empty(list + prio)) { qdisc->q.qlen--; - return skb; + return __qdisc_dequeue_head(qdisc, list + prio); } }