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
|