Subject: Re: [RFC 6/6] fib_trie: combine leaf and info

From: Stephen Hemminger <[email-masked]>
Date: Tue, 15 Jan 2008 10:15:43 -0800

On Tue, 15 Jan 2008 19:10:31 +0100
Eric Dumazet <[email-masked]> wrote:

> On Tue, 15 Jan 2008 09:47:53 -0800
> Stephen Hemminger <[email-masked]> wrote:
> 
> > This is how I did it:
> > 
> > --- a/net/ipv4/fib_trie.c	2008-01-15 09:14:53.000000000 -0800
> > +++ b/net/ipv4/fib_trie.c	2008-01-15 09:21:48.000000000 -0800
> > @@ -101,13 +101,6 @@ struct node {
> >  	t_key key;
> >  };
> >  
> > -struct leaf {
> > -	unsigned long parent;
> > -	t_key key;
> > -	struct hlist_head list;
> > -	struct rcu_head rcu;
> > -};
> > -
> >  struct leaf_info {
> >  	struct hlist_node hlist;
> >  	struct rcu_head rcu;
> > @@ -115,6 +108,13 @@ struct leaf_info {
> >  	struct list_head falh;
> >  };
> >  
> > +struct leaf {
> > +	unsigned long parent;
> > +	t_key key;
> > +	struct hlist_head list;
> > +	struct rcu_head rcu;
> > +};
> 
> I like this :)
> 
> Your design is clean, but we waste some space (rcu in leaf_info "included"), we probably can do a litle bit better
> (moving rcu at the end of leaf_info, and kmem_cache_create("ip_fib_trie", sizeof(struct leaf) + sizeof(struct_leaf_info) - sizeof(struct rcu_head))
> 
>  
> > -	trie_leaf_kmem = kmem_cache_create("ip_fib_trie", sizeof(struct leaf),
> > +	trie_leaf_kmem = kmem_cache_create("ip_fib_trie",
> > +					   sizeof(struct leaf) + sizeof(struct leaf_info),
> >  					   0, SLAB_PANIC, NULL);
> >  }
> >  
> > 
> 
> Thank you

Having multiple RCU links is a waste. I started on code that just splice's the
leaf_info's off to a free_list and then do a mass free after and RCU barrier.

For the normal case of just freeing a leaf, it could just walk the chain
in the RCU free of the leaf.

-- 
Stephen Hemminger <[email-masked]>