[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.1209031041340.1663@ja.ssi.bg>
Date: Mon, 3 Sep 2012 11:22:15 +0300 (EEST)
From: Julian Anastasov <ja@....bg>
To: Eric Dumazet <eric.dumazet@...il.com>
cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
Stephen Hemminger <shemminger@...tta.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Subject: Re: [PATCH v2 1/2] tcp: add generic netlink support for
tcp_metrics
Hello,
On Mon, 3 Sep 2012, Eric Dumazet wrote:
> On Sun, 2012-09-02 at 08:36 +0300, Julian Anastasov wrote:
> > +
> > +static int tcp_metrics_flush_all(struct net *net)
> > +{
> > + unsigned int max_rows = 1U << net->ipv4.tcp_metrics_hash_log;
> > + struct tcpm_hash_bucket *hb = net->ipv4.tcp_metrics_hash;
> > + struct tcp_metrics_block *tm;
> > + unsigned int sync_count = 0;
> > + unsigned int row;
> > +
> > + for (row = 0; row < max_rows; row++, hb++) {
> > + spin_lock_bh(&tcp_metrics_lock);
> > + tm = deref_locked_genl(hb->chain);
> > + if (tm)
> > + hb->chain = NULL;
> > + spin_unlock_bh(&tcp_metrics_lock);
> > + while (tm) {
> > + struct tcp_metrics_block *next;
> > +
> > + next = deref_genl(tm->tcpm_next);
> > + kfree_rcu(tm, rcu_head);
> > + if (!((++sync_count) & 2047))
> > + synchronize_rcu();
> > + tm = next;
> > + }
> > + }
> > + return 0;
> > +}
>
> It looks like the synchronize_rcu() call is not exactly what you wanted,
> but then net/ipv4/fib_trie.c has the same mistake.
I used fib_trie as reference...
> What we want here is to force pending call_rcu() calls to complete, so
> that we dont consume too much memory. So it would probably better to
> call rcu_barrier() instead.
I see
> If other cpus are idle or outside of rcu read lock sections,
> synchronize_rcu() should basically do nothing at all.
>
> But I am not sure its worth the trouble ?
>
> Commit c3059477fce2d956a0bb3e04357324780c5d8eeb (ipv4: Use
> synchronize_rcu() during trie_rebalance()) was needed because FIB TRIE
> can really use huge amounts of memory, thats hardly the case with
> tcp_metrics.
I was worrying for the case
(TCP_METRICS_RECLAIM_DEPTH + 1) * tcpmhash_entries to be
large, eg. if some non-default value is configured. May be the
chance table to be filled immediately is small. I'll remove it.
BTW, is it appropriate to use kmem_cache for
metrics and as result call_rcu for freeing?
Regards
--
Julian Anastasov <ja@....bg>
--
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