Skip to content

Commit 512bb43

Browse files
Jarek Poplawskidavem330
authored andcommitted
pkt_sched: sch_htb: Optimize WARN_ONs in htb_dequeue_tree() etc.
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>
1 parent 1b5c007 commit 512bb43

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/sched/sch_htb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
726726
u32 *pid;
727727
} stk[TC_HTB_MAXDEPTH], *sp = stk;
728728

729-
WARN_ON(!tree->rb_node);
729+
BUG_ON(!tree->rb_node);
730730
sp->root = tree->rb_node;
731731
sp->pptr = pptr;
732732
sp->pid = pid;
@@ -746,9 +746,10 @@ static struct htb_class *htb_lookup_leaf(struct rb_root *tree, int prio,
746746
*sp->pptr = (*sp->pptr)->rb_left;
747747
if (sp > stk) {
748748
sp--;
749-
WARN_ON(!*sp->pptr);
750-
if (!*sp->pptr)
749+
if (!*sp->pptr) {
750+
WARN_ON(1);
751751
return NULL;
752+
}
752753
htb_next_rb_node(sp->pptr);
753754
}
754755
} else {
@@ -779,8 +780,7 @@ static struct sk_buff *htb_dequeue_tree(struct htb_sched *q, int prio,
779780

780781
do {
781782
next:
782-
WARN_ON(!cl);
783-
if (!cl)
783+
if (unlikely(!cl))
784784
return NULL;
785785

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

0 commit comments

Comments
 (0)