netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: Srivatsa Vaddagiri <vatsa@in.ibm.com>
Cc: davem@redhat.com, netdev@oss.sgi.com,
	linux-kernel@vger.kernel.org, Dipankar <dipankar@in.ibm.com>,
	paulmck@us.ibm.com
Subject: Re: [RFC] Use RCU for tcp_ehash lookup
Date: Tue, 31 Aug 2004 15:54:20 +0200	[thread overview]
Message-ID: <20040831135419.GA17642@wotan.suse.de> (raw)
In-Reply-To: <20040831125941.GA5534@in.ibm.com>

On Tue, Aug 31, 2004 at 06:29:41PM +0530, Srivatsa Vaddagiri wrote:
> 
>   I would be interested to know if anyone has seen high-rate of lock contention
>   for hash bucket lock. Such workloads would benefit from the lock-free lookup.

I would suspect something that does IO from multiple threads over 
a single connection. However there is also the socket lock, which
may prevent too much parallelism.
> 
>   In the absence of any workload which resulted in lock contention, I resorted
>   to disabling NAPI and irq balance (noirqbalance) to study the effect of cache
>   bouncing on the lookup routine. The result was that CPU usage of the stack
>   was halved in lock-free case, which IMHO, is a strong enough reason for us
>   to consider this seriously.

Yes, sounds very nice.

I bet also when you just do rdtsc timing for the TCP receive
path the cycle numbers will be way down (excluding the copy).

And it should also fix the performance problems with
cat /proc/net/tcp on ppc64/ia64 for large hash tables because the rw locks 
are gone.

>   
> - I presume that one of the reasons for keeping the hash table so big is to
>   keep lock contention low (& to reduce the size of hash chains). If the lookup
>   is made lock-free, then could the size of the hash table be reduced (without
>   adversely impacting performance)?

Definitely worth trying IMHO. The current hash tables are far
too big. I would do that as followon patches though.

I haven't studied it in detail (yet), just two minor style 
comments: 


> -		sk_free(sk);
> +sp_loop:
> +	if (atomic_dec_and_test(&sk->sk_refcnt)) {
> +		/* Restore ref count and schedule callback.
> +		 * If we don't restore ref count, then the callback can be
> +		 * scheduled by more than one CPU.
> +		 */
> +		atomic_inc(&sk->sk_refcnt);
> +
> +		if (atomic_read(&sk->sk_refcnt) == 1)
> +			call_rcu(&sk->sk_rcu, sk_free_rcu);
> +		else
> +			goto sp_loop;
> +	}

Can you rewrite that without goto? 
> +tput_loop:
>  	if (atomic_dec_and_test(&tw->tw_refcnt)) {
> -#ifdef INET_REFCNT_DEBUG
> -		printk(KERN_DEBUG "tw_bucket %p released\n", tw);
> -#endif
> -		kmem_cache_free(tcp_timewait_cachep, tw);
> +		/* Restore ref count and schedule callback.
> +		 * If we don't restore ref count, then the callback can be
> +		 * scheduled by more than one CPU.
> +		 */
> +
> +		atomic_inc(&tw->tw_refcnt);
> +
> +		if (atomic_read(&tw->tw_refcnt) == 1)
> +			call_rcu(&tw->tw_rcu, tcp_tw_free);
> +		else
> +			goto tput_loop;

And that too.


-Andi

  parent reply	other threads:[~2004-08-31 13:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-31 12:59 [RFC] Use RCU for tcp_ehash lookup Srivatsa Vaddagiri
2004-08-31 13:04 ` Srivatsa Vaddagiri
2004-08-31 13:12 ` Srivatsa Vaddagiri
2004-08-31 13:54 ` Andi Kleen [this message]
2004-09-01 11:36   ` Srivatsa Vaddagiri
2004-09-02  5:45     ` David S. Miller
2004-09-02 21:19     ` Andi Kleen
2004-09-02  5:43   ` David S. Miller
2004-09-02  5:41 ` David S. Miller
2004-09-02 14:04   ` Srivatsa Vaddagiri
2004-09-02 16:31   ` Paul E. McKenney

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=20040831135419.GA17642@wotan.suse.de \
    --to=ak@suse.de \
    --cc=davem@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=paulmck@us.ibm.com \
    --cc=vatsa@in.ibm.com \
    /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).