diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-01-23 00:51:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:10:56 -0500 |
commit | bc3c8c1e02ae89668239742fd592f21e1998fa46 (patch) | |
tree | 48f941a414c89d6e3b070f5ad3a4976a02ea9004 /net | |
parent | a1f6f5a7689098f01d9b7b7181795ee78563ce37 (diff) |
[IPV4] fib_trie: put leaf nodes in a slab cache
This improves locality for operations that touch all the leaves. Save
space since these entries don't need to be hardware cache aligned.
Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/fib_trie.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index a52334d30cf8..9291e7c41fc7 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -162,6 +162,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn); | |||
162 | static void tnode_free(struct tnode *tn); | 162 | static void tnode_free(struct tnode *tn); |
163 | 163 | ||
164 | static struct kmem_cache *fn_alias_kmem __read_mostly; | 164 | static struct kmem_cache *fn_alias_kmem __read_mostly; |
165 | static struct kmem_cache *trie_leaf_kmem __read_mostly; | ||
165 | 166 | ||
166 | static inline struct tnode *node_parent(struct node *node) | 167 | static inline struct tnode *node_parent(struct node *node) |
167 | { | 168 | { |
@@ -325,7 +326,8 @@ static inline void alias_free_mem_rcu(struct fib_alias *fa) | |||
325 | 326 | ||
326 | static void __leaf_free_rcu(struct rcu_head *head) | 327 | static void __leaf_free_rcu(struct rcu_head *head) |
327 | { | 328 | { |
328 | kfree(container_of(head, struct leaf, rcu)); | 329 | struct leaf *l = container_of(head, struct leaf, rcu); |
330 | kmem_cache_free(trie_leaf_kmem, l); | ||
329 | } | 331 | } |
330 | 332 | ||
331 | static void __leaf_info_free_rcu(struct rcu_head *head) | 333 | static void __leaf_info_free_rcu(struct rcu_head *head) |
@@ -375,7 +377,7 @@ static inline void tnode_free(struct tnode *tn) | |||
375 | 377 | ||
376 | static struct leaf *leaf_new(void) | 378 | static struct leaf *leaf_new(void) |
377 | { | 379 | { |
378 | struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL); | 380 | struct leaf *l = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL); |
379 | if (l) { | 381 | if (l) { |
380 | l->parent = T_LEAF; | 382 | l->parent = T_LEAF; |
381 | INIT_HLIST_HEAD(&l->list); | 383 | INIT_HLIST_HEAD(&l->list); |
@@ -1938,7 +1940,12 @@ out: | |||
1938 | void __init fib_hash_init(void) | 1940 | void __init fib_hash_init(void) |
1939 | { | 1941 | { |
1940 | fn_alias_kmem = kmem_cache_create("ip_fib_alias", sizeof(struct fib_alias), | 1942 | fn_alias_kmem = kmem_cache_create("ip_fib_alias", sizeof(struct fib_alias), |
1941 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); | 1943 | 0, SLAB_PANIC, NULL); |
1944 | |||
1945 | trie_leaf_kmem = kmem_cache_create("ip_fib_trie", | ||
1946 | max(sizeof(struct leaf), | ||
1947 | sizeof(struct leaf_info)), | ||
1948 | 0, SLAB_PANIC, NULL); | ||
1942 | } | 1949 | } |
1943 | 1950 | ||
1944 | 1951 | ||