Skip to content

Commit

Permalink
pkt_sched: sch_htb: Optimize WARN_ONs in htb_dequeue_tree() etc.
Browse files Browse the repository at this point in the history
We can skip WARN_ON() in htb_dequeue_tree() because there should be
always a similar warning from htb_lookup_leaf() earlier.

The first WARN_ON() in in htb_lookup_leaf() is changed to BUG_ON()
because most likly this should end with oops anyway.

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jarek Poplawski authored and David S. Miller committed Dec 10, 2008
1 parent 1b5c007 commit 512bb43
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/sched/sch_htb.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
u32 *pid;
} stk[TC_HTB_MAXDEPTH], *sp = stk;

WARN_ON(!tree->rb_node);
BUG_ON(!tree->rb_node);
sp->root = tree->rb_node;
sp->pptr = pptr;
sp->pid = pid;
Expand All @@ -746,9 +746,10 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
*sp->pptr = (*sp->pptr)->rb_left;
if (sp > stk) {
sp--;
WARN_ON(!*sp->pptr);
if (!*sp->pptr)
if (!*sp->pptr) {
WARN_ON(1);
return NULL;
}
htb_next_rb_node(sp->pptr);
}
} else {
Expand Down Expand Up @@ -779,8 +780,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio,

do {
next:
WARN_ON(!cl);
if (!cl)
if (unlikely(!cl))
return NULL;

/* class can be empty - it is unlikely but can be true if leaf
Expand Down

0 comments on commit 512bb43

Please sign in to comment.