Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote: > On Fri, 2014-03-07 at 14:37 +0100, Florian Westphal wrote: > > > + /* no match, need to insert new node */ > > + rbconn = kmem_cache_alloc(connlimit_rb_cachep, GFP_ATOMIC); > > + if (rbconn == NULL) > > + goto out; > > > > conn = kmem_cache_alloc(connlimit_conn_cachep, GFP_ATOMIC); > > - if (conn == NULL) > > - return false; > > + if (conn == NULL) { > > + kmem_cache_free(connlimit_rb_cachep, rbconn); > > + goto out; > > + } > > + > > conn->tuple = *tuple; > > conn->addr = *addr; > > - hlist_add_head(&conn->node, head); > > - return true; > > + rbconn->addr = *addr; > > + > > + INIT_HLIST_HEAD(&rbconn->hhead); > > + hlist_add_head(&conn->node, &rbconn->hhead); > > + > > + rb_link_node(&rbconn->node, parent, rbnode); > > + rb_insert_color(&rbconn->node, root); > > + count = 1; > > + out: > > + tree_nodes_free(root, gc_nodes, gc_count); > > + return count; > > } > > Very nice work Florian Thanks Eric. > I would call tree_nodes_free() _before_ attempting the > kmem_cache_alloc(), so that the allocation can reuse a hot object that > you freed right before allocation. Hmm, that would be nice. I need to think about it again, problem is that moving it at this time could result in freeing the would-be parent of the new node. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html