[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080114164621.2bc5011f@deepthought>
Date: Mon, 14 Jan 2008 16:46:21 -0800
From: Stephen Hemminger <stephen.hemminger@...tta.com>
To: David Miller <davem@...emloft.net>
Cc: robert.olsson@....uu.se, netdev@...r.kernel.org
Subject: [PATCH 3/6] [IPV4] trie: put leaf nodes in a slab cache
This improves locality for operations that touch all the leaves.
Later patch will grow the size of the leaf so it becomes more
important.
Signed-off-by: Stephen Hemminger <stephen.hemminger@...tta.com>
--- a/net/ipv4/fib_trie.c 2008-01-14 12:26:51.000000000 -0800
+++ b/net/ipv4/fib_trie.c 2008-01-14 13:41:00.000000000 -0800
@@ -162,6 +162,7 @@ static struct tnode *halve(struct trie *
static void tnode_free(struct tnode *tn);
static struct kmem_cache *fn_alias_kmem __read_mostly;
+static struct kmem_cache *trie_leaf_kmem __read_mostly;
static inline struct tnode *node_parent(struct node *node)
{
@@ -316,7 +317,8 @@ static inline void alias_free_mem_rcu(st
static void __leaf_free_rcu(struct rcu_head *head)
{
- kfree(container_of(head, struct leaf, rcu));
+ struct leaf *leaf = container_of(head, struct leaf, rcu);
+ kmem_cache_free(trie_leaf_kmem, leaf);
}
static void __leaf_info_free_rcu(struct rcu_head *head)
@@ -366,7 +368,7 @@ static inline void tnode_free(struct tno
static struct leaf *leaf_new(void)
{
- struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL);
+ struct leaf *l = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
if (l) {
l->parent = T_LEAF;
INIT_HLIST_HEAD(&l->list);
@@ -1927,6 +1929,9 @@ void __init fib_hash_init(void)
{
fn_alias_kmem = kmem_cache_create("ip_fib_alias", sizeof(struct fib_alias),
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
+
+ trie_leaf_kmem = kmem_cache_create("ip_fib_trie", sizeof(struct leaf),
+ 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists