Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp182475ima; Thu, 14 Mar 2019 23:52:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyWRi44vLP15g06uqHSS1Ir8tNo2Ok99FN8WsfsPTXUsPDYZtb/p+3xHOxn+p3qlc+ebNK X-Received: by 2002:a62:4299:: with SMTP id h25mr2372237pfd.165.1552632774034; Thu, 14 Mar 2019 23:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552632774; cv=none; d=google.com; s=arc-20160816; b=R52a8447TeHEzVWge8DW7VKsIdPXIIW/i6rdo4sAMf1mQftsIEN4gzu0jVMGpG8AyI QDwiL8YKvu80dZHJUbvha8OIAgVlaanndQ1jKIyZfm2a6Fw1+vCitjvwcrK1Nin1USfa vghvo4AV2ez8dyKRJ0q/CIdzBFFvrhvWhQeiNAG9QV33eAOonGYCvoxq4DywQL6UdKY9 k2rhgEtmnlVCOX7TZVK3Zt3VD9JKLqIGwrznLnkZOvp0T0opy5aLdAWkMCR3UGAw7Y0n wo1hFQbu+dpklxDPWVakT45mZyBbhh44uYVoQGLXu/FGidGsoCFc3NKJquA+5SfO89n0 9cpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:references :in-reply-to:subject:cc:date:to:from; bh=N3YhYzdsfP4SvlrcVi+mOl+ru2yqxGbj26WkEe9cMwg=; b=rCiBhVHInapm/DduZgOWk9rbyjP9qMeSTaojF4unoYjjOfyI3BijZHVjENygZqu+Iz pjVb/87/c+QkN1zKkWrObbiKS7RBDnBAJaxUCoqD+gQG1khgQT3w6fHL47StaM5ZjU63 R8tvwzo4YktX9FZZ3aqDEYlmBzS2aNVREE+uwQldSWoCPhVUrRZsSaiRhvqIOjroETT0 Znxh1TVHvWqEq5QGgkeAekyQRQQh87k4y/06suyizUTSlVZmiuJYH0+1A/cp09/bXnEH kaAFhrROj+QP+oSY+i0asiFLvV8wIo9E+l4SoCK41uH7azpdPg2Z5ax2Jt4wY2t5266K tsXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12si1164555pfp.104.2019.03.14.23.52.38; Thu, 14 Mar 2019 23:52:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbfCOGwD (ORCPT + 99 others); Fri, 15 Mar 2019 02:52:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:56306 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727905AbfCOGwD (ORCPT ); Fri, 15 Mar 2019 02:52:03 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0082DACEC; Fri, 15 Mar 2019 06:52:01 +0000 (UTC) From: NeilBrown To: Herbert Xu Date: Fri, 15 Mar 2019 17:51:55 +1100 Cc: Thomas Graf , netdev@vger.kernel.org, "Paul E. McKenney" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] rhashtable: use cmpxchg() in nested_table_alloc() In-Reply-To: <20190315051029.waqb3ohztl7w6zep@gondor.apana.org.au> References: <155253979234.5022.1840929790507376038.stgit@noble.brown> <155253992824.5022.10318044793639169265.stgit@noble.brown> <20190315051029.waqb3ohztl7w6zep@gondor.apana.org.au> Message-ID: <87lg1gocj8.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. >>=20 >> 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. >>=20 >> Signed-off-by: NeilBrown >> --- >> 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlyLS4sACgkQOeye3VZi gblQUQ//RBzixG4gFwOatP9rLrNit/9H4cnPHvtaJOIdW56aCWCUa8L5/BaPOKNP vbQA/17jXhVYYpLQHtB94j3g+gCZ48uF3heolfwMejbYeheionbwrw+h/zEmS2MF 3zi25k6hzybkO6TEsNotPG0cJ+99wT7AGqlZm+EzHEjKW1K8T7DWbcGaYx/2c7ZY MpnE46wbDSWBuROuHH3WFUHC23O6TyUcHaRaA3yfHkrVBsLCo1sy+NX7NLBYSERe EzgmocJ0l4wUBlQeet3tGlShCv2jdPm6cloelE8E8rys4E1h5pH/2m4FtxUgkPmZ KqnlJog7EnqM2J02OO3M1yY2GjIDlSvQSv4Fx2ig6fPN0Wn8/yXOYy+fzmMR8BOl gBT//zy+ENSHogo4eJLqV6//3g1OkWk8LYXp6te7z3tCHiXI0XMvNxHuJSgzhkUS Y7PahZ2ZSRPa28xKiCbkj8LF1+gN6qF+QIT1Ofnzxdpp4AKNuX5PXMXNUIHLdcAh AAT/hHsqM/T5qt44IGR54EtUq0w6hXymVGuqC4Qj7HsWsw54v1m4Xikwi58NjGSr ZKeUqahKHZwcI4Sg1s4t/EwSOJzyiK6F76Mbb1PYZzbVGJd2Mrm2QCEJ61wkDEbR rTBcUyF+P2GZO4HaAi4PzDkHIF7wOmx8rlw41q/BILxslS0P1zg= =f/1C -----END PGP SIGNATURE----- --=-=-=--