Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283131

Re: rhashtable: Prevent spurious EBUSY errors on insertion

From Phil Sutter <phil@nwl.cc>
Newsgroups linux.kernel
Subject Re: rhashtable: Prevent spurious EBUSY errors on insertion
Date 2015-12-03 16:40 +0100
Message-ID <qBE9c-6XG-7@gated-at.bofh.it> (permalink)
References <qwXvP-1JB-15@gated-at.bofh.it> <qAt6b-1Ny-17@gated-at.bofh.it> <qAtIR-2gq-1@gated-at.bofh.it> <qAtIR-2gq-15@gated-at.bofh.it> <qBBuH-53y-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Dec 03, 2015 at 08:41:29PM +0800, Herbert Xu wrote:
> On Mon, Nov 30, 2015 at 06:18:59PM +0800, Herbert Xu wrote:
> > 
> > OK that's better.  I think I see the problem.  The test in
> > rhashtable_insert_rehash is racy and if two threads both try
> > to grow the table one of them may be tricked into doing a rehash
> > instead.
> > 
> > I'm working on a fix.
> 
> OK this patch fixes the EBUSY problem as far as I can tell.  Please
> let me know if you still observe EBUSY with it.  I'll respond to the
> ENOMEM problem in another email.
> 
> ---8<---
> 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 <tgraf@suug.ch>
> Reported-by: Phil Sutter <phil@nwl.cc>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Tested-by: Phil Sutter <phil@nwl.cc>
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

rhashtable: Prevent spurious EBUSY errors on insertion Herbert Xu <herbert@gondor.apana.org.au> - 2015-12-03 13:50 +0100
  Re: rhashtable: Prevent spurious EBUSY errors on insertion Phil Sutter <phil@nwl.cc> - 2015-12-03 16:40 +0100
  Re: rhashtable: Prevent spurious EBUSY errors on insertion David Miller <davem@davemloft.net> - 2015-12-04 20:40 +0100

csiph-web