netdev
[Top] [All Lists]

Re: [patch] do not readlock all buckets in /proc/net/tcp

To: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx>
Subject: Re: [patch] do not readlock all buckets in /proc/net/tcp
From: Marcus Meissner <meissner@xxxxxxx>
Date: Mon, 5 Jul 2004 14:45:11 +0200
Cc: netdev@xxxxxxxxxxx
In-reply-to: <20040705.212522.126409437.yoshfuji@xxxxxxxxxxxxxx>
References: <E1BhRda-0001Rs-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20040705113555.GA28665@xxxxxxx> <20040705120610.GA5728@xxxxxxxxxxxxxxxxxxx> <20040705.212522.126409437.yoshfuji@xxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6i
On Mon, Jul 05, 2004 at 09:25:22PM +0900, YOSHIFUJI Hideaki / 吉藤英明 wrote:
> In article <20040705120610.GA5728@xxxxxxxxxxxxxxxxxxx> (at Mon, 5 Jul 2004 
> 22:06:10 +1000), Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> says:
> 
> > On Mon, Jul 05, 2004 at 01:35:55PM +0200, Marcus Meissner wrote:
> > > 
> > > Oh, and NETLINK+TCP_DIAG seems to have the same readlock contention 
> > > problem,
> > > see tcpdiag_dump().
> > 
> > Then you wouldn't mind adding this optimisation for tcp_diag as well,
> > right? :)
> 
> here it is. :-)
> 
> Signed-off-by: Hideaki YOSHIFUJI <yoshfuji@xxxxxxxxxxxxxx>
> 
> ===== net/ipv4/tcp_diag.c 1.15 vs edited =====
> --- 1.15/net/ipv4/tcp_diag.c  2004-06-08 07:27:58 +09:00
> +++ edited/net/ipv4/tcp_diag.c        2004-07-05 21:18:17 +09:00
> @@ -522,9 +522,13 @@
>               if (i > s_i)
>                       s_num = 0;
>  
> -             read_lock_bh(&head->lock);
> -
>               num = 0;
> +
> +             if (hlist_empty(&head->chain) &&
> +                 (!(r->tcpdiag_states&TCPF_TIME_WAIT) || 
> hlist_empty(&head->chain)))
> +                     continue;

The second hlist_empty is bad, you should be checking &tcp_ehash[i +
tcp_ehash_size].chain ((head+tcp_ehash_size) I think).


Ciao, Marcus


<Prev in Thread] Current Thread [Next in Thread>