Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755509AbbLDTis (ORCPT ); Fri, 4 Dec 2015 14:38:48 -0500 Received: from shards.monkeyblade.net ([149.20.54.216]:41019 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753746AbbLDTir (ORCPT ); Fri, 4 Dec 2015 14:38:47 -0500 Date: Fri, 04 Dec 2015 14:38:44 -0500 (EST) Message-Id: <20151204.143844.1840501199234860407.davem@davemloft.net> To: herbert@gondor.apana.org.au Cc: phil@nwl.cc, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, tgraf@suug.ch, fengguang.wu@intel.com, wfg@linux.intel.com, lkp@01.org Subject: Re: rhashtable: Prevent spurious EBUSY errors on insertion From: David Miller In-Reply-To: <20151203124129.GA5505@gondor.apana.org.au> References: <20151130101401.GA17712@orbit.nwl.cc> <20151130101859.GA8378@gondor.apana.org.au> <20151203124129.GA5505@gondor.apana.org.au> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 04 Dec 2015 11:38:46 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1396 Lines: 30 From: Herbert Xu Date: Thu, 3 Dec 2015 20:41:29 +0800 > Thomas and Phil observed that under stress rhashtable insertion > sometimes failed with EBUSY, even though this error should only > ever been seen when we're under attack and our hash chain length > has grown to an unacceptable level, even after a rehash. > > It turns out that the logic for detecting whether there is an > existing rehash is faulty. In particular, when two threads both > try to grow the same table at the same time, one of them may see > the newly grown table and thus erroneously conclude that it had > been rehashed. This is what leads to the EBUSY error. > > This patch fixes this by remembering the current last table we > used during insertion so that rhashtable_insert_rehash can detect > when another thread has also done a resize/rehash. When this is > detected we will give up our resize/rehash and simply retry the > insertion with the new table. > > Reported-by: Thomas Graf > Reported-by: Phil Sutter > Signed-off-by: Herbert Xu Looks good, applied, thanks Herbert. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/