Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3134599imm; Sun, 3 Jun 2018 20:39:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXlO4unWaxLEA7bxViAJfxazfkzJ9WHkw/gSZmqPi2ayfioBKBfKqW5wPgeeEv1p/8CByn X-Received: by 2002:aa7:8551:: with SMTP id y17-v6mr19412172pfn.163.1528083579965; Sun, 03 Jun 2018 20:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528083579; cv=none; d=google.com; s=arc-20160816; b=n7fcShbunENCUH/mqI5m8uH0aBCKjzmp7KQ7ofof33rztBwuStkI5+AOt41UbIpRt3 m5KpuVMuDasgJ4+1KdU8hpodvXZqFcX9ORLe2+fEajeuUbqSNGx9wiXE80TMFzO3CuHD BV4sYGiUd4HFtjyFzSWmEcyKvDvEIxV89VinFqCPkpyUGyV+vR5LDxbR4Y5GboDBnXF2 TCHPjlL9NcsRTGXUCNxM+iYsPg/3CkDj99w1W/x0IxlTIYbzqpOyk8bjADaHvGcCGxVv LEIFmh+u+coYUIi5HoYeNUInsoLRwdpVJeuZKisc6Ez7NhDoHvK90wEHg2BvdxZT4xl/ HseA== 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:arc-authentication-results; bh=dqRbdyGcJXqSx4ieHpPAvSPKr9JStudLFjop2Pj1tt4=; b=rxFW/fAEe2un8fbSmb8hiKH+8zTeplAy10sD4DmpuEhSKOLG3HDqEnPG2LfBSDrR9q BcZtZ5eXzrrK+DUqQCdpERdnwg7wiRskItKXqUpt39QbClh2vLa7woQIWyUGWkui2FR1 i+9H3Ishg3q6U2wuNpgAWLvz48x517th0WqZX2t6e11l6KVH/4auokQSo+d/6pwopXvA yMxZojRNKsSDpaFaT//NpmYadCUa8JySZqG8Y+ur/xVLsbmbweDkHtX84MSag91WzJdu SVkWn1jhfy8hkkcmbN4oi1zrTMr61j3B3M5/z53gnxdqrky38WzmFYZNWOBpMsXeQ5gz 2Pqg== 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 p25-v6si20198782pfi.345.2018.06.03.20.39.24; Sun, 03 Jun 2018 20:39:39 -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 S1751597AbeFDDi7 (ORCPT + 99 others); Sun, 3 Jun 2018 23:38:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:59146 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbeFDDi6 (ORCPT ); Sun, 3 Jun 2018 23:38:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 19703AC23; Mon, 4 Jun 2018 03:38:57 +0000 (UTC) From: NeilBrown To: Herbert Xu Date: Mon, 04 Jun 2018 13:38:46 +1000 Cc: Thomas Graf , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: Re: [PATCH 04/18] rhashtable: detect when object movement might have invalidated a lookup In-Reply-To: <20180601160613.7ud25g2ux55k3bma@gondor.apana.org.au> References: <152782754287.30340.4395718227884933670.stgit@noble> <152782824943.30340.8224535954517915320.stgit@noble> <20180601160613.7ud25g2ux55k3bma@gondor.apana.org.au> Message-ID: <87k1rfp6ex.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 Sat, Jun 02 2018, Herbert Xu wrote: > On Fri, Jun 01, 2018 at 02:44:09PM +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. >>=20 >> The unique NULLS_MARKER is derived from the address of the >> head of the chain. > > Yes I thinks makes a lot more sense than the existing rhashtable > nulls code. The current rhashtable nulls code harkens back to the > time of the old rhashtable implementation where the same chain > existed in two different tables and that is no longer the case. > >> 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 > > This is not currently required by TCP/UDP. I'd rather not add > extra constraints that aren't actually used. I assume you are referring here to the change to insert at the head of the chain, rather than at the end. This is important for me to be able to use SLAB_TYPESAFE_BY_RCU for the kmem_cache. Without that, I need a new rcu-free callback for every different kmem_cache. When using SLAB_TYPESAFE_BY_RCU, there is no way to know where a freed and re-allocated object might be used again - it could be used in the same table with the same hash value. Thanks, NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlsUtEYACgkQOeye3VZi gbnJzw/9E3yArpPPJiNiuoT4TsqGwH2v2iO8Qd2lfOTp43Y2MPCmgsxGsstwT0Lr SXlzelx1tjlhzTebWbDB3d/oHWBUMcEJKqqez+r0LFQq+qHIBjjgizi0R0mxBbfg ADOPtzK7ONFG5/s8aYHb7OHhNO8cLE2mvHXhv1iu/EzxDqoI4xAtviI8EZegCGup PQwMGFczxtX7kJ/c1ENqDxBQSWVGOjZQ5NvtlQYgoszIj28UuY7ln/4x9Fg3bMNv bq4ZsBGod+rR/y+w7e3HG1/6rp6vbqlBS4thrqecD50nV3pNR36nLjJ4CaTqmzgZ sDDohnjCa4UVtYl8JNiI7g7sRZYbejf4BLMq8cEowyvZZiMwxgWGolW8v/whOxp4 RYFcmaSfU9jP8njQOunkRUvT2JfNe9/Ab9dMwkC+HPK603JnV6BASHtC4bwZtyAM afM5+0qD4o2kGxDYUDSD+XgRwGpV4w94IGdax/vtH3lTG3/utIJAV2TKaGmXpP4A NGI4D8qjEWekICaX8+ZSOcMamFiOhvNtyPRaPdV2S0TOKOXmOlZiVlDwYK7iwLHd OjJMfgduEHS9ACp1b/uvqpj1j4Tx0bOYzm+A+AUU2BJMiH3rZLzmVoAfDrm3HQFR hgp36mVDVZUEh1tHTLbvAsyl0/1clpW7ZAy5Vic4yXxYOicwX7U= =skn/ -----END PGP SIGNATURE----- --=-=-=--