Received: by 10.192.165.148 with SMTP id m20csp1535677imm; Sat, 5 May 2018 14:51:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqzn8qBBHyTFfM7ZNDP7/0Y8wZipsbkSueDeWRCWBCbTwX+Egdo2Ahs4S6A9Ta/FWavTGbq X-Received: by 2002:a17:902:462:: with SMTP id 89-v6mr32302446ple.300.1525557101690; Sat, 05 May 2018 14:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525557101; cv=none; d=google.com; s=arc-20160816; b=zFZAFRo7cdvm80VBpYtpBrmywnGVIfHVwEubX21n0EBBrqaUHHzYwD/Xu7D69ZSKDm bN0gRWm6+YL1AbGE66RwbilQPfgcSfxZDj9RzoDhBEi8Yr+QiqjcVOX9d96C9FYrF4YH h+l/g4dZiVtbTzA0gc86zyQ6h5b1TueLzLrytULZwsaem6EXXCEOdPBgCoTDjsf0YNa/ c9GEBpwsZId9oYDnCXJu7+bLAkG/RyTsun7gQgDXwgytX/ahz87vXcyYqi7IZ4ZaS9A/ hg85Q6W95X7/HxMlVIBxDrxwQn4gQsBD5E/Z+q+bVm7qB7s6n+XSioWrAGK8EAOUM7wR IV2w== 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=CocUPR5YeraPorHaHVgFidDpQOAvJf4bzteLM0jICLk=; b=XWWoaejN1vnWNXXYRDUtnlXlrXCIp4OEiBMk71g83dWHRLDVwDaYnlHHZq97bKp0+q XZH39zYJLPdrSNfCrqSrQT9GZmQ5+sybhPsnPPjjl3ZgVwTAR4FYqNFLMHnMIdBPA98o JE4wddYXQl/tgR1Gr2qdf6IbW/SFxU1TDGoChe7EP1MmzclBYt0QBsbIlJA6Fwzk54Uz V88p1A3qvCAVkRVW3SVnMK9INkrc3Lvf9+9geaBNi6Aj+mYagOaq0V+u/hG0ISt/sj8n LBPjePlujCcjZ7UbTUU+fBk7dUJwsbP/FghAsiydcXp6kfydAdglKFPSetvn5jrhXyId xrzw== 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 n10-v6si7133068pgq.472.2018.05.05.14.51.26; Sat, 05 May 2018 14:51:41 -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 S1751903AbeEEVvD (ORCPT + 99 others); Sat, 5 May 2018 17:51:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:47214 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243AbeEEVvC (ORCPT ); Sat, 5 May 2018 17:51:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7BE04AF5D; Sat, 5 May 2018 21:51:00 +0000 (UTC) From: NeilBrown To: Herbert Xu Date: Sun, 06 May 2018 07:50:54 +1000 Cc: Thomas Graf , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/8] rhashtable: further improve stability of rhashtable_walk In-Reply-To: <20180505094212.hpqjyv5ijibviuwh@gondor.apana.org.au> References: <152540595840.18473.11298241115621799037.stgit@noble> <152540605438.18473.4797800779538116583.stgit@noble> <20180505094212.hpqjyv5ijibviuwh@gondor.apana.org.au> Message-ID: <87vac1db5t.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, May 05 2018, Herbert Xu wrote: > On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote: >> If the sequence: >> obj =3D rhashtable_walk_next(iter); >> rhashtable_walk_stop(iter); >> rhashtable_remove_fast(ht, &obj->head, params); >> rhashtable_walk_start(iter); >>=20 >> races with another thread inserting or removing >> an object on the same hash chain, a subsequent >> rhashtable_walk_next() is not guaranteed to get the "next" >> object. It is possible that an object could be >> repeated, or missed. >>=20 >> This can be made more reliable by keeping the objects in a hash chain >> sorted by memory address. A subsequent rhashtable_walk_next() >> call can reliably find the correct position in the list, and thus >> find the 'next' object. >>=20 >> It is not possible (certainly not so easy) to achieve this with an >> rhltable as keeping the hash chain in order is not so easy. When the >> first object with a given key is removed, it is replaced in the chain >> with the next object with the same key, and the address of that >> object may not be correctly ordered. >> No current user of rhltable_walk_enter() calls >> rhashtable_walk_start() more than once, so no current code >> could benefit from a more reliable walk of rhltables. >>=20 >> This patch only attempts to improve walks for rhashtables. >> - a new object is always inserted after the last object with a >> smaller address, or at the start >> - when rhashtable_walk_start() is called, it records that 'p' is not >> 'safe', meaning that it cannot be dereferenced. The revalidation >> that was previously done here is moved to rhashtable_walk_next() >> - when rhashtable_walk_next() is called while p is not NULL and not >> safe, it walks the chain looking for the first object with an >> address greater than p and returns that. If there is none, it moves >> to the next hash chain. >>=20 >> Signed-off-by: NeilBrown > > I'm a bit torn on this. On the hand this is definitely an improvement > over the status quo. On the other this does not work on rhltable and > we do have a way of fixing it for both rhashtable and rhltable. Do we? How could we fix it for both rhashtable and rhltable? Thanks, NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlruJz4ACgkQOeye3VZi gblVqA/9F7ZODtO/+GOk5akFPqS0M10RD4YyDXTAfbgj0s7tamZXDzXuFPa4VwAK oLcLgcySX/kfrff6BLv1Z8Y2XqZQKo1cnpxlxf4uhUraoIWcawNARL21TXE/58c0 QVGJEBEofx1uVkifXH4cwuwyNdGbdNEOIVAIUCG71NLFWjiF1nO/xDQx5/RCM8IY KlPRSAJI8dIY2JMhE5Gc8GvRyoQueR14ExUxb5Adc/LfamhBuDD+jWofshQgtKvn fSFHOrNet0MpwdY7GRZMX+A3dphelJKZwQ3FCqXK2vsl/S1sge7tWJpMI6gUxb9M A7eNe2H8FR4E42z8RhjyyplZ6tMA9LM9PCHqOI2tbGwLfwQcXzqF/ZLia7BYb50Y hKBk+JcPMFwHuc33pJ1WhS5fIhQhAmn0gkcKIZb8fGmDcjAbWgks9QHBW51mBoMT lle6mKZ5WQuHQyxzqmztdIMJTrHcq7xiGF0MtHyXhnVlOIwOMm7ID6M67iGeTjrR 8EeuPvynf/iRpQTywh3vchK5Q9WiqWh//ACdFbVFilBrrvXgUKYWx1NlAVXOJS00 A8+gqcdJ6skbi5+/sXp9Sb7ekgsHk4pwRCu4XIp4oanDdGxI8FkUvfm1SII6EqCZ V+wZUayhgmzv0y3YlpwYEKvaGIlbAaNC0B/MgFfjhzA5m6cMiXI= =S76l -----END PGP SIGNATURE----- --=-=-=--