Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp929802imm; Wed, 18 Jul 2018 13:15:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcZWuc6tvZgjxLZzOqvL2/tr1/yuMN42uCrMlV1I1SmPjuvk4LY4GQj4Kd0KJKcMiUH/vZg X-Received: by 2002:a63:6fcc:: with SMTP id k195-v6mr7174089pgc.135.1531944934103; Wed, 18 Jul 2018 13:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531944934; cv=none; d=google.com; s=arc-20160816; b=iDduD5exHI8KtAWXS8wW1EVs3SuZtuFAPt64eYfoHFeG4eXJL/ZdZM4EQrt5tIIo5C EuDUIB3U0ssJLuEZ7EjTi31lSIScozeRAWTnRV6sIssqmFpT4ob34SMBOl/VcK14Fp2j ZSA0d4y9jAAhlAr9ZTOeMifev6jUByu6HcVgfRC1yl8Nclws0OSmqzInYHshsjei+BvG r64/RPjgwGbpfcpZu87gF5nhSPVIBN6MJj2iKuH8YRFXs1yzeXrASLcBfyHIfTkyGR3z V06eKiSIqgyi85WEq/1ZF4rV2pNBjkDidQ3ivbiwR1VhxPHCGy4mKZzKzLQ72hmk9T44 WZNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date :arc-authentication-results; bh=bxokx+KuwIk1dVvF1a/ZPm6xQfkuZp3EzPE/cUlymR4=; b=zoHKsnNn55qEy0mAOQgwD+ktvUgSl1Dd6iI4Z59kB5vofDyL/VjtfHVET0XcdJY9Tk l3iRzx7xzRI06I0I3S3yakhwzbz4DaHfrVri+PdJdQlA9pKSJqr/88hWfv7j3a/0vlrd m5tZ0ulTQlGKkOA+jY1ZPPrz7uGW4qQ0mad40coDOjxWrIN1yEAsn12KRMf/xyzkjten HU7Ml9S8v/ZDEiALDp3V7tJ9KBOMyJeAwRpQESgjaQ/sjq/yWORpOqvJnoo702gp5Dfe zCXPmpAlQjaFrbyijy1KsO15yj0DI1duHCTsXs9YF0DoVkvGDSDNr3fkbql56quNhHa6 Is5Q== 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 v22-v6si3821419plo.123.2018.07.18.13.15.18; Wed, 18 Jul 2018 13:15:34 -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 S1730693AbeGRUyL (ORCPT + 99 others); Wed, 18 Jul 2018 16:54:11 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:42752 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730123AbeGRUyK (ORCPT ); Wed, 18 Jul 2018 16:54:10 -0400 Received: from localhost (179-64-212-66.spl.org [66.212.64.179]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id B51191473D1B4; Wed, 18 Jul 2018 13:14:40 -0700 (PDT) Date: Thu, 19 Jul 2018 05:14:40 +0900 (KST) Message-Id: <20180719.051440.931407144963903326.davem@davemloft.net> To: neilb@suse.com Cc: herbert@gondor.apana.org.au, tgraf@suug.ch, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com Subject: Re: [PATCH - revised] rhashtable: detect when object movement might have invalidated a lookup From: David Miller In-Reply-To: <87fu0kt5m0.fsf@notabene.neil.brown.name> References: <20180711.224658.2077863065492745521.davem@davemloft.net> <20180711.224801.1129067473269289703.davem@davemloft.net> <87fu0kt5m0.fsf@notabene.neil.brown.name> X-Mailer: Mew version 6.7 on Emacs 26 / 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]); Wed, 18 Jul 2018 13:14:40 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: NeilBrown Date: Mon, 16 Jul 2018 09:57:11 +1000 > Some users of rhashtable might need to change the key > of an object and move it to a different location in the table. > Other users might want to allocate objects using > SLAB_TYPESAFE_BY_RCU which can result in the same memory allocation > being used for a different (type-compatible) purpose and similarly > end up in a different hash-chain. > > To support these, we store a unique NULLS_MARKER at the end of > each chain, and when a search fails to find a match, we check > if the NULLS marker found was the expected one. If not, > the search is repeated. > > The unique NULLS_MARKER is derived from the address of the > head of the chain. > > If an object is removed and re-added to the same hash chain, we won't > notice by looking that the NULLS marker. In this case we must be sure > that it was not re-added *after* its original location, or a lookup may > incorrectly fail. The easiest solution is to ensure it is inserted at > the start of the chain. insert_slow() already does that, > insert_fast() does not. So this patch changes insert_fast to always > insert at the head of the chain. > > Note that such a user must do their own double-checking of > the object found by rhashtable_lookup_fast() after ensuring > mutual exclusion which anything that might change the key, such as > successfully taking a new reference. > > Signed-off-by: NeilBrown Neil I have to be honest with you. During this whole ordeal I was under the impression that this was all going to be used for something in-tree. But now I see that you want to use all of this stuff for lustre which is out of tree. It would be extremely hard for me to accept adding this kind of complexity and weird semantics to an already extremely complicated and delicate piece of infrastructure if something in-tree would use it. But for something out-of-tree? I'm sorry, no way.