netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 7/7] netfilter: connlimit: use rbtree for per-host conntrack obj storage
Date: Fri, 7 Mar 2014 17:15:12 +0100	[thread overview]
Message-ID: <20140307161512.GF17526@breakpoint.cc> (raw)
In-Reply-To: <1394203677.20149.18.camel@edumazet-glaptop2.roam.corp.google.com>

Eric Dumazet <eric.dumazet@gmail.com> 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.

  reply	other threads:[~2014-03-07 16:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 13:37 [PATCH 0/7] netfilter: connlimit: scalability improvements Florian Westphal
2014-03-07 13:37 ` [PATCH 1/7] netfilter: connlimit: factor hlist search into new function Florian Westphal
2014-03-07 13:37 ` [PATCH 2/7] netfilter: connlimit: improve packet-to-closed-connection logic Florian Westphal
2014-03-07 13:37 ` [PATCH 3/7] netfilter: connlimit: move insertion of new element out of count function Florian Westphal
2014-03-07 13:37 ` [PATCH 4/7] netfilter: connlimit: use kmem_cache for conn objects Florian Westphal
2014-03-07 13:37 ` [PATCH 5/7] netfilter: connlimit: use keyed locks Florian Westphal
2014-03-09 17:13   ` Jan Engelhardt
2014-03-09 18:31     ` Florian Westphal
2014-03-07 13:37 ` [PATCH 6/7] netfilter: connlimit: make same_source_net signed Florian Westphal
2014-03-07 13:37 ` [PATCH 7/7] netfilter: connlimit: use rbtree for per-host conntrack obj storage Florian Westphal
2014-03-07 14:47   ` Eric Dumazet
2014-03-07 16:15     ` Florian Westphal [this message]
2014-03-09 18:42       ` Eric Dumazet
2014-03-09 18:43         ` Florian Westphal
2014-03-09 21:45           ` Florian Westphal
2014-03-12 12:58 ` [PATCH 0/7] netfilter: connlimit: scalability improvements Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140307161512.GF17526@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=eric.dumazet@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).