diff mbox

rib_trie / Fix inflate_threshold_root. Now=15 size=11 bits

Message ID 20090626180544.GA6908@ami.dom.local
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Jarek Poplawski June 26, 2009, 6:05 p.m. UTC
On Fri, Jun 26, 2009 at 10:05:38AM -0700, Paul E. McKenney wrote:
...
> In that case, simply invoking synchronize_rcu() every once and awhile
> should take care of things.  This could be at the end of every large
> trie operation, or you could even count the call_rcu() invocations and
> do a synchronize_rcu() every 100th, 1,000th, or whatever, based on
> the amount of memory available.

OK, for now the minimal change for testing (2.6.30 needs previously
mentioned two commits from 2.6.31-rc). (I guess I'll send it with a
changelog after net-next is opened.)

Thanks,
Jarek P.
--- (take 4 - for testing)

 net/ipv4/fib_trie.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Paul E. McKenney June 26, 2009, 6:21 p.m. UTC | #1
On Fri, Jun 26, 2009 at 08:05:45PM +0200, Jarek Poplawski wrote:
> On Fri, Jun 26, 2009 at 10:05:38AM -0700, Paul E. McKenney wrote:
> ...
> > In that case, simply invoking synchronize_rcu() every once and awhile
> > should take care of things.  This could be at the end of every large
> > trie operation, or you could even count the call_rcu() invocations and
> > do a synchronize_rcu() every 100th, 1,000th, or whatever, based on
> > the amount of memory available.
> 
> OK, for now the minimal change for testing (2.6.30 needs previously
> mentioned two commits from 2.6.31-rc). (I guess I'll send it with a
> changelog after net-next is opened.)

Looks promising to me!!!

							Thanx, Paul

> Thanks,
> Jarek P.
> --- (take 4 - for testing)
> 
>  net/ipv4/fib_trie.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index 012cf5a..98b31a1 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
> @@ -1008,7 +1008,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
>  {
>  	int wasfull;
>  	t_key cindex, key;
> -	struct tnode *tp;
> +	struct tnode *tp, *oldtnode = tn;
> 
>  	key = tn->key;
> 
> @@ -1028,8 +1028,12 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
>  	}
> 
>  	/* Handle last (top) tnode */
> -	if (IS_TNODE(tn))
> +	if (IS_TNODE(tn)) {
> +		/* force memory freeing after last changes */
> +		if (oldtnode != tn)
> +			synchronize_rcu();
>  		tn = (struct tnode *)resize(t, (struct tnode *)tn);
> +	}
> 
>  	rcu_assign_pointer(t->trie, (struct node *)tn);
>  	tnode_free_flush();
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarek Poplawski June 26, 2009, 8:19 p.m. UTC | #2
On Fri, Jun 26, 2009 at 11:21:43AM -0700, Paul E. McKenney wrote:
> On Fri, Jun 26, 2009 at 08:05:45PM +0200, Jarek Poplawski wrote:
> > On Fri, Jun 26, 2009 at 10:05:38AM -0700, Paul E. McKenney wrote:
> > ...
> > > In that case, simply invoking synchronize_rcu() every once and awhile
> > > should take care of things.  This could be at the end of every large
> > > trie operation, or you could even count the call_rcu() invocations and
> > > do a synchronize_rcu() every 100th, 1,000th, or whatever, based on
> > > the amount of memory available.
> > 
> > OK, for now the minimal change for testing (2.6.30 needs previously
> > mentioned two commits from 2.6.31-rc). (I guess I'll send it with a
> > changelog after net-next is opened.)
> 
> Looks promising to me!!!
> 

Alas, after rethinking, there is one detail which bothers me. Those
largest allocs here are done with vmalloc and freed with RCU by
schedule_work(). So, I wonder if just because of this, the previous
version doing it directly isn't more reliable anyway. Of course, it's
my bad I didn't point it while describing the problem earlier. (I knew
I missed something...;-)

Thanks,
Jarek P.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 012cf5a..98b31a1 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1008,7 +1008,7 @@  static void trie_rebalance(struct trie *t, struct tnode *tn)
 {
 	int wasfull;
 	t_key cindex, key;
-	struct tnode *tp;
+	struct tnode *tp, *oldtnode = tn;
 
 	key = tn->key;
 
@@ -1028,8 +1028,12 @@  static void trie_rebalance(struct trie *t, struct tnode *tn)
 	}
 
 	/* Handle last (top) tnode */
-	if (IS_TNODE(tn))
+	if (IS_TNODE(tn)) {
+		/* force memory freeing after last changes */
+		if (oldtnode != tn)
+			synchronize_rcu();
 		tn = (struct tnode *)resize(t, (struct tnode *)tn);
+	}
 
 	rcu_assign_pointer(t->trie, (struct node *)tn);
 	tnode_free_flush();