netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Thomas Graf <tgraf@suug.ch>,
	netdev@vger.kernel.org,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] rhashtable: use cmpxchg() in nested_table_alloc()
Date: Fri, 15 Mar 2019 17:51:55 +1100	[thread overview]
Message-ID: <87lg1gocj8.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20190315051029.waqb3ohztl7w6zep@gondor.apana.org.au>

[-- Attachment #1: Type: text/plain, Size: 1598 bytes --]

On Fri, Mar 15 2019, Herbert Xu wrote:

> Hi Neil:
>
> On Thu, Mar 14, 2019 at 04:05:28PM +1100, NeilBrown wrote:
>> nested_table_alloc() relies on the fact that there is
>> at most one spinlock allocated for every slot in the top
>> level nested table, so it is not possible for two threads
>> to try to allocate the same table at the same time.
>> 
>> This assumption is a little fragile (it is not explicit) and is
>> unnecessary.  We can instead protect against
>> a race using cmpxchg() - if it the cmp fails, free the table
>> that was just allocated.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>>  lib/rhashtable.c |    8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> You probably explained it to me before but it's been long enough
> that I no longer remember why we need this change.  So please
> explain in the commit log why this change is needed.  Because
> on the face of it you are adding locking/sychronisation and not
> taking it away.
>

I hoped the patch could be justified on the basis that the current
behaviour is fragile - the dependency that a single spin lock covers a
while slot (and all children) in the top-level nested table is not at
all obvious.

I do have a stronger reason though - I want the replace the spinlocks
with bit-spin-locks.  With those we will only hold a lock for the
particular chain being worked on.  If you need that extra explanation to
justify the patch, I'll hold it over until the other two patches land
and the rest of the bit-spin-lock series is ready.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2019-03-15  6:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  5:05 [PATCH 0/3] Three rhashtable improvements NeilBrown
2019-03-14  5:05 ` [PATCH 2/3] rhashtable: don't hold lock on first table throughout insertion NeilBrown
2019-03-14 14:58   ` Paul E. McKenney
2019-03-15  5:47   ` Herbert Xu
2019-03-15  6:46     ` NeilBrown
2019-03-20  5:40       ` Herbert Xu
2019-03-14  5:05 ` [PATCH 3/3] rhashtable: rename rht_for_each*continue as *from NeilBrown
2019-03-15  5:49   ` Herbert Xu
2019-03-17  7:50   ` Miguel Ojeda
2019-03-18  0:15     ` NeilBrown
2019-03-14  5:05 ` [PATCH 1/3] rhashtable: use cmpxchg() in nested_table_alloc() NeilBrown
2019-03-15  5:10   ` Herbert Xu
2019-03-15  6:51     ` NeilBrown [this message]
2019-03-20  5:41       ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg1gocj8.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).