Received: with ECARTIS (v1.0.0; list netdev); Mon, 27 Sep 2004 15:00:51 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8RM0fU1013460 for ; Mon, 27 Sep 2004 15:00:42 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1CC3Xh-0000dx-00; Tue, 28 Sep 2004 08:00:21 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1CC3Xb-0001yY-00; Tue, 28 Sep 2004 08:00:15 +1000 From: Herbert Xu To: herbert@gondor.apana.org.au (Herbert Xu) Subject: Re: [6/6]: jenkins hash for neigh Cc: davem@davemloft.net, herbert@gondor.apana.org.au, laforge@gnumonks.org, netdev@oss.sgi.com Organization: Core In-Reply-To: X-Newsgroups: apana.lists.os.linux.netdev User-Agent: tin/1.7.4-20040225 ("Benbecula") (UNIX) (Linux/2.4.27-hx-1-686-smp (i686)) Message-Id: Date: Tue, 28 Sep 2004 08:00:15 +1000 X-archive-position: 9540 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev Content-Length: 718 Lines: 22 Herbert Xu wrote: > > Please at least do something like this: > > size = tbl->hash_mask + 1; > if (tbl->entries > size) { > write_lock_bh(&tbl->lock); > neigh_hash_grow(tbl, size << 1); > write_unlock_bh(&tbl->lock); > } > > That'll at least kill the first race. You can kill the race of > growing into the same size by doing the if check again inside the > locks. Never mind. Unless you do the check again inside the lock this may actually shrink :) -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt