Skip to content

Commit

Permalink
[PKT_SCHED]: Reduce branch mispredictions in pfifo_fast_dequeue
Browse files Browse the repository at this point in the history
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 <dada1@cosmosbay.com>
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 <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
tgraf authored and davem330 committed Jul 18, 2005
1 parent d7c7ed4 commit 452f299
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 452f299

Please sign in to comment.