Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2452997yba; Sun, 7 Apr 2019 19:37:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx85GGZKJGba/98GxddyrfzxRdvtzBsmt/4n/igUIKCnrGE/O6YT/IztngeTbNIuOuewYYZ X-Received: by 2002:a17:902:380c:: with SMTP id l12mr26471383plc.238.1554691025539; Sun, 07 Apr 2019 19:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554691025; cv=none; d=google.com; s=arc-20160816; b=v0yyHLfw7aNaVBew46mougyuWfh60a8b1yZUJezMDwfznALkfI0cUnYKOoazIZ+7jU QfhSmp3holTeuS8CHLWXiEuUYdZ4+yIcVLAsFo3wc4TZ8uCTVOWrTDa9uQ6Tj0ZLfsy/ 1VZ5rf7+kqUAJWijwBUOVKcrAR88vKLEYc+YCUgL8UDelsaNe1m3+DOO8MDxcobEULzk kiKRMuf9lIN0VCwabOvWw4dYXDQgOnI9YjfoEzTOxeLCB7fIo8L8whN5Js4DFhqUQL0u 4nsm2/pr3HRXNLzKOUmf3X7miPYyk136Zq+/Wti3T46wWcy/A0hUfen9bcDk5m044rDY dvhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=UsNy4TG+VPFneVB+/pM52ZCb35YMDt11Vo05eyAPtH8=; b=c4yiT67/NlKVUab0TX0pKo71BCazSq3MMp3T7AGAsz4aJKxiu/vQPKydkaQUt5d76n hsIhbDIOaEEMeHE64eHHHb7I7TypfEaqPchLmi7jijNP9CD2a8I38sexZfWjukVamQ4/ bNxlQGiNhTIUs+XxWFQ/XLcpi10TZO5OBbWMIaXJAny4UX5lsR2vBPYjdzBIpGavz7qJ PUJQHoS2ua1t4nieKPg9TaaaZTXVzY/zfrW+/Sex4Xtt4rqieLrH30IWDvXePShonWH2 f/NIzA49Ph6uOUAAml5aQ7nJYhSCAmd7gp+RfyLK6FHq5LdaSwszYwxfJGhjoAZEEUhL lLGw== 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 d2si24509741pgq.129.2019.04.07.19.36.50; Sun, 07 Apr 2019 19:37:05 -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 S1726668AbfDHCev (ORCPT + 99 others); Sun, 7 Apr 2019 22:34:51 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:33210 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbfDHCeu (ORCPT ); Sun, 7 Apr 2019 22:34:50 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1hDK7S-0005gC-6U; Mon, 08 Apr 2019 10:34:46 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1hDK7S-0003By-0a; Mon, 08 Apr 2019 10:34:46 +0800 Date: Mon, 8 Apr 2019 10:34:46 +0800 From: Herbert Xu To: NeilBrown Cc: Thomas Graf , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] rhashtable: use cmpxchg() in nested_table_alloc() Message-ID: <20190408023445.ihid3a6tx6k37xhd@gondor.apana.org.au> References: <155416000985.9540.14182958463813560577.stgit@noble.brown> <155416006508.9540.3368212864327714370.stgit@noble.brown> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <155416006508.9540.3368212864327714370.stgit@noble.brown> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 02, 2019 at 10:07:45AM +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 as cmpxchg() can be used instead. > > A future patch will replace the spinlocks by per-bucket bitlocks, > and then we won't be able to protect the slot pointer with a spinlock. > > So replace rcu_assign_pointer() with cmpxchg() - which has equivalent > barrier properties. > If it the cmp fails, free the table that was just allocated. > > Signed-off-by: NeilBrown Acked-by: Herbert Xu -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt