Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1520121imu; Tue, 11 Dec 2018 22:42:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/WHm28/+VJixxWTo6xxhDPRXuE0eMo0YduYW+R/vvehOIPZVE4RY2ysh1qyaaTCDuKAQzeM X-Received: by 2002:a62:6303:: with SMTP id x3mr19775295pfb.110.1544596972839; Tue, 11 Dec 2018 22:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544596972; cv=none; d=google.com; s=arc-20160816; b=sXRJePU8vK7eFWYXnT/QCR/3/Tc5kkk8u2EUyzV3bqBxemY3dc5TiM02O0mi4KQih7 zPb7brVhNyjlURFeeT9nT9PnAxcHRzT6/t8aliyQHYG+hav5tSmVP6QjTxP1OBDF2EGd GWarl/XxfYro/mwHXttrCzQHJcGRry3c/QL+AxyeMNYUZ4tmEFEyROZCxMaYwVVH/vUj DMxqnOHVdv+uoPkrxHqMDn+pgEIQHrY83eywZACTScpF//3bhrMC893mDH1OhqZ4DknD 2fUMJGbzWYmbHjgEE/99nbXlC6KHbrVffd5TgL/k7vdXr00+FRsw/GpxxwtIiMV1e9NU qp5g== 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; bh=qzzUtW0zyB8Grxtn98vFGXhoREzkKMRnl6jH3NlwdrI=; b=xlduQkelvzCBvcywGycuLHpPCpp5CG7SJEJyl4ve84LWhreQiUmcOaxa2OSboGUBiF 81WjfDvHaMD+EoHLOMpvJBaL1PMxhBmir+n3elxIZbtjPgDt7bCzf8J2hPudeJ3B2J+D fWjXY9WlaORM67v9j0tn20bY7ny91xf+NykQZOFhuPgu2/IVa1U87gTLUi4rBAuIADay Uv+XBunMXk90GCIjPZAsK25Ocx/Mu/5kI0Jglpz6SXwx9+PO6rCMjHza5jcXSlQQAObk kQmLlaTiiZAUV+pZrQoiOS7yW5tNXEPyVeYZ0+gT88t0gZV8lGColqfycR6fmyobf2rI nwJw== 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 f23si12911747pgv.431.2018.12.11.22.42.38; Tue, 11 Dec 2018 22:42:52 -0800 (PST) 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 S1726554AbeLLGll (ORCPT + 99 others); Wed, 12 Dec 2018 01:41:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:33902 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726242AbeLLGll (ORCPT ); Wed, 12 Dec 2018 01:41:41 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 25E0BAFDC; Wed, 12 Dec 2018 06:41:38 +0000 (UTC) From: NeilBrown To: Herbert Xu Date: Wed, 12 Dec 2018 17:41:29 +1100 Cc: Thomas Graf , Tom Herbert , David Miller , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] rhashtable: further improve stability of rhashtable_walk In-Reply-To: <20181212054601.wbzpxjunnsfi62mz@gondor.apana.org.au> References: <153086101070.2825.6850140624411927465.stgit@noble> <153086109256.2825.15329014177598382684.stgit@noble> <87zhtkeimx.fsf@notabene.neil.brown.name> <20181207053943.7zacyn5uvqkfnfoi@gondor.apana.org.au> <87k1kico1o.fsf@notabene.neil.brown.name> <20181211051755.modgomqzszkbiihe@gondor.apana.org.au> <87mupbvch0.fsf@notabene.neil.brown.name> <20181212054601.wbzpxjunnsfi62mz@gondor.apana.org.au> Message-ID: <87efanuu06.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 Wed, Dec 12 2018, Herbert Xu wrote: > On Wed, Dec 12, 2018 at 11:02:35AM +1100, NeilBrown wrote: >>=20 >> So I think this is a real bug - it is quite unlikely to hit, but >> possibly. >> You need a chain with at least 2 objects, you need >> rhashtable_walk_stop() to be called after visiting an object other than >> the last object, and you need some thread (this or some other) to remove >> that object from the table. >>=20 >> The patch that I posted aims to fix that bug, and only that bug. >> The only alternative that I can think of is to document that this can >> happen and advise that a reference should be held to the last visited >> object when stop/start is called, or in some other way ensure that it >> doesn't get removed. > > Thanks for reminding me of the issue you were trying to fix. > > So going back into the email archives, I suggested at the very > start that we could just insert the walker objects into the actual > hash table. That would solve the issue for both rhashtable and > rhlist. > > Could we do that rather than using this ordered list that only > works for rhashtable? No. that doesn't work. When you remove the walker object from the hash chain, you need to wait for the RCU grace period to expire before you can safely insert back into the chain. Inserting into a different chain isn't quite so bad now that the nulls-marker stuff is working, a lookup thread will notice the move and retry the lookup. So you would substantially slow down the rhashtable_walk_start() step. I've tried to think of various ways to over come this problem, such as walking backwards through each chain - it is fairly safe to move and object earlier in the chain - but all the approaches I have tried make the code much more complex. Thanks, NeilBrown > > Cheers, > --=20 > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlwQrZoACgkQOeye3VZi gbmV5g//bkJtiWIR+EH/pwBVgpR0vLOZAc19P0GXhARLjEuS1oI1eiLekpjHmxqc 0BIqWba2YJEg4G3+igBHrk6fviNf3flPJ2xMyo8ixuN0/YwgJLmx+Jc7t1Va++G9 zaYDnYCzLDjsqF8A/ncj8vhuA1sn9hn3gHJxb2/EXlbMuCwHVJRx912d5bzllMxh 2a3IX+deB+2MNGg5Rp/yos9a2vH689k7Tjt5k1spILclCj8usLRQACZfMHqxpXBR qYOtRbgCfnDPRjS/tQSbeA+kGEivRlKGMZ07hFgqUdkf9cza+lPeNSB9mOpCA6Wv iXo8rU2+Yju3ob229rToC9O6fMDVzSsHe+gM0TNNGEW7dyYX254tBuOHSXjMyOAA 7kabmicOODsQ361wROgr7xx7b3Ahzt6LiCs94msTW+C/efXDx0by7Uum1NjfFPC9 pCEYK3KoDME4/gOWa2kppLbTuKqidhZfKr2o8cxbl92volMHZJD1VI8YTDrE2F1Y 8F9Dt4buZWzMJMTm6808J2PAvsfHJ9CVnKpXf40me3P57RUQLGthWf3Oj37w87Qy ReOXe87XVn87k8hbO9JLChmSxt0lQkVtA7JoCgi7nrq4C4WNkM+H3LK7Ahwst3l3 D+NTSo+Gf9J9Si0qCMm5QGrnmB+YL3f6UwQefYAcfwTYaeg6sao= =MLM/ -----END PGP SIGNATURE----- --=-=-=--