aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-04-10 06:47:34 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-10 06:47:34 -0400
commit387a5487f5a1f8bfc3b2c5818e50dfd19eeb4f3f (patch)
treeb8e6fdea41532619eecb1d1dd3f546194d855226 /net/ipv4/fib_trie.c
parentef3660ce0649fa10265455f539b72607cff53d02 (diff)
ipv4: fib_trie leaf free optimization
Avoid unneeded test in the case where object to be freed has to be a leaf. Don't need to use the generic tnode_free() function, instead just setup leaf to be freed. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 595a2eedb2dc..1ada5a6b03ea 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -163,7 +163,6 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n,
163static struct node *resize(struct trie *t, struct tnode *tn); 163static struct node *resize(struct trie *t, struct tnode *tn);
164static struct tnode *inflate(struct trie *t, struct tnode *tn); 164static struct tnode *inflate(struct trie *t, struct tnode *tn);
165static struct tnode *halve(struct trie *t, struct tnode *tn); 165static struct tnode *halve(struct trie *t, struct tnode *tn);
166static void tnode_free(struct tnode *tn);
167 166
168static struct kmem_cache *fn_alias_kmem __read_mostly; 167static struct kmem_cache *fn_alias_kmem __read_mostly;
169static struct kmem_cache *trie_leaf_kmem __read_mostly; 168static struct kmem_cache *trie_leaf_kmem __read_mostly;
@@ -337,6 +336,11 @@ static void __leaf_free_rcu(struct rcu_head *head)
337 kmem_cache_free(trie_leaf_kmem, l); 336 kmem_cache_free(trie_leaf_kmem, l);
338} 337}
339 338
339static inline void free_leaf(struct leaf *l)
340{
341 call_rcu_bh(&l->rcu, __leaf_free_rcu);
342}
343
340static void __leaf_info_free_rcu(struct rcu_head *head) 344static void __leaf_info_free_rcu(struct rcu_head *head)
341{ 345{
342 kfree(container_of(head, struct leaf_info, rcu)); 346 kfree(container_of(head, struct leaf_info, rcu));
@@ -377,10 +381,9 @@ static void __tnode_free_rcu(struct rcu_head *head)
377 381
378static inline void tnode_free(struct tnode *tn) 382static inline void tnode_free(struct tnode *tn)
379{ 383{
380 if (IS_LEAF(tn)) { 384 if (IS_LEAF(tn))
381 struct leaf *l = (struct leaf *) tn; 385 free_leaf((struct leaf *) tn);
382 call_rcu_bh(&l->rcu, __leaf_free_rcu); 386 else
383 } else
384 call_rcu(&tn->rcu, __tnode_free_rcu); 387 call_rcu(&tn->rcu, __tnode_free_rcu);
385} 388}
386 389
@@ -1091,7 +1094,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
1091 li = leaf_info_new(plen); 1094 li = leaf_info_new(plen);
1092 1095
1093 if (!li) { 1096 if (!li) {
1094 tnode_free((struct tnode *) l); 1097 free_leaf(l);
1095 return NULL; 1098 return NULL;
1096 } 1099 }
1097 1100
@@ -1127,7 +1130,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
1127 1130
1128 if (!tn) { 1131 if (!tn) {
1129 free_leaf_info(li); 1132 free_leaf_info(li);
1130 tnode_free((struct tnode *) l); 1133 free_leaf(l);
1131 return NULL; 1134 return NULL;
1132 } 1135 }
1133 1136
@@ -1583,7 +1586,7 @@ static void trie_leaf_remove(struct trie *t, struct leaf *l)
1583 } else 1586 } else
1584 rcu_assign_pointer(t->trie, NULL); 1587 rcu_assign_pointer(t->trie, NULL);
1585 1588
1586 tnode_free((struct tnode *) l); 1589 free_leaf(l);
1587} 1590}
1588 1591
1589/* 1592/*