Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1804380imm; Sun, 15 Jul 2018 17:52:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe95ciaOxsvLV+5YfySswI6U1O+vxF9WXI/PI89MGYKVwE9BkyNyfdl5SbDTTJe09xlXNmh X-Received: by 2002:a63:2644:: with SMTP id m65-v6mr13585931pgm.371.1531702352268; Sun, 15 Jul 2018 17:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531702352; cv=none; d=google.com; s=arc-20160816; b=0mQC5vdov0z6hie2qeea1lA/FtW7g1T0AwTkxJB9oJsnCsQXc0HexTU97Ti/zVyhkL XfvObsI3BknQiFfYRZhNo16xYMm+EP48UltD+uJb6sweQzRGjEdStD3KlUS1U3OBukGx DcFLi57DwCEBpHJvxUgc2lvtY7eMDwNR/7yC/YqiNGL62LEJRkePai4L1MMe7L618aAK EtCU0npwjOUDKELigKmM9dYz2MueFOH6wFYpyyI0Im0awQ7ZBt6olbEcyiysoAnp2IHa cn9W9Of4NDwxwndlvjG5JeDJZFIoIl30kYzj2I84DDanDAnDo+MEAjAEgUANlPUxIoKG JJ3A== 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:arc-authentication-results; bh=Ge/Qg0SVhuGOpeuaOURlhuUA+P9pJ3Uhq/hvexXd39Q=; b=WhZTYQO1sE38PlZ/hJQNBGCUCSmpCinvlrfKJyGwg57F5dyiSJpF8H5MteDHAQidoj 5eadblrxhgjzodvMySqvgAe8rOEVcRSWzMGuQ07GVZWTxhzmljaHVyfuLmcCSlDTKfNv sdyzddPwzMs4d/M//5n31KrmiVcQTFIbhHJj+8RWDosLDwVwDTjel4Uevm5U7et29SEG 0FEvAEpA9wHnnw2BCmGUWeRRo8ms5mI2CMU1gIT8x7PsG+Jh5l4HPXFH5ShRjP1/Ad7w xMKiFlYa7TyzZ8rcq07RQeXAE1fv3RfY9DDSJLndTcNBzzQ1R7bPY7dNqqaWmze1hB1F UqLg== 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 k7-v6si5075664pgk.595.2018.07.15.17.52.17; Sun, 15 Jul 2018 17:52:32 -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 S1727354AbeGPBQe (ORCPT + 99 others); Sun, 15 Jul 2018 21:16:34 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:34394 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727184AbeGPBQe (ORCPT ); Sun, 15 Jul 2018 21:16:34 -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 1ferjm-0002bk-TP; Mon, 16 Jul 2018 08:51:39 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1ferjj-0001rC-4N; Mon, 16 Jul 2018 08:51:35 +0800 Date: Mon, 16 Jul 2018 08:51:35 +0800 From: Herbert Xu To: NeilBrown Cc: David Miller , 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 Message-ID: <20180716005134.q4rfkfn3m5zzwt62@gondor.apana.org.au> References: <20180601160613.7ud25g2ux55k3bma@gondor.apana.org.au> <87k1q8yh70.fsf@notabene.neil.brown.name> <20180711.224658.2077863065492745521.davem@davemloft.net> <20180711.224801.1129067473269289703.davem@davemloft.net> <87fu0kt5m0.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fu0kt5m0.fsf@notabene.neil.brown.name> 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 Mon, Jul 16, 2018 at 09:57:11AM +1000, NeilBrown wrote: > > 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 I still don't understand why we need this feature. The only existing user of this (which currently doesn't use rhashtable) does not readd the reused entry to the same table. IOW the flow is always from table A to table B. After which the entry will be properly freed rather than reused. So who is going to use this? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt