Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp597818imu; Thu, 13 Dec 2018 00:49:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXlEWEPE+TIf1QAkJTfUeQ17eVHXFTijeE/Vea0UHPQjBC9EAFEN/1WKYBgMohCXx9BTx1 X-Received: by 2002:a17:902:a601:: with SMTP id u1mr22840827plq.77.1544690967999; Thu, 13 Dec 2018 00:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544690967; cv=none; d=google.com; s=arc-20160816; b=oNg9oNLKUmb8Pni6sbGEw/au6FGZMRy+6WKxO5+oBhBxCqnpeJkxEyuMM8AL5PQtB0 cIgxoOTLatZhLCt7cG8jPsLNA4AnHDWDhRK4/SYl2IQ/q/6TfbFp8NTUJ93lsZG5ff4+ Kuc2pjYwzfvwFkXCSJvRlyj0HTbKs+s4zpF5Hh0NqxoNmzhcnYv90mdaH2i62NdWhYDR RorI8WSBflIyOkK9hkCZApj7qWrT17fuPZYy7BOZTuoxRiPBFRCiQz2o8lIeHhERdL3D J01zk7dGOmFrlY9Ou+7x5jgyWSEiPJ+8aknPEm/KizC070rgxCP/FclO2dV8w4LCI0PT BJrA== 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; bh=yLqyZCGh9LPgF0ZbEvt4usCJ3BSrMjN4KHNFoU37Azk=; b=D9/e6eyyAmyIrITzZmGWofgG7UEgUB+Kd1bxLguhIVgyXq7CJH0bSwUwsF95JNskqN UkQHkxnJdUwASj3YxrboiIdRL9J8IbobBQycstBOi+sH8JiBqSKtzC2F7EY2/ai89Mzg kcQIcVeYSmdGr/Kv5FjmUz7gxCKiQG9ZR/CTWIgZg4IQQxs/sAdYwjNqcxQbrpm25iuX qeNDZ+wHOZ26mg6uOgovtlvV6zF+S4CcnYODGtB3hR8yC76REIhkHNtdr5k77CHQLAVh 7QC5tc1ORpO4cOAvBKpRSbAYYga0DaE4p+rh+5VZAWHIpXl4BjLOfj2IJdxE8/ytJNQf B0MA== 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 p11si1042493pgb.219.2018.12.13.00.49.12; Thu, 13 Dec 2018 00:49:27 -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 S1727480AbeLMIsH (ORCPT + 99 others); Thu, 13 Dec 2018 03:48:07 -0500 Received: from orcrist.hmeau.com ([104.223.48.154]:50040 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbeLMIsF (ORCPT ); Thu, 13 Dec 2018 03:48:05 -0500 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 1gXMf0-0001D9-ND; Thu, 13 Dec 2018 16:47:58 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1gXMex-0004Qc-Rt; Thu, 13 Dec 2018 16:47:55 +0800 Date: Thu, 13 Dec 2018 16:47:55 +0800 From: Herbert Xu To: NeilBrown 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 Message-ID: <20181213084755.3kdwdd53qyasdwfw@gondor.apana.org.au> References: <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> <87efanuu06.fsf@notabene.neil.brown.name> <20181212080037.j2zs22t57uxdu2jr@gondor.apana.org.au> <87bm5ruo3f.fsf@notabene.neil.brown.name> <20181213014309.uufaeoijhympgxbz@gondor.apana.org.au> <8736r2ulw4.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8736r2ulw4.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 Thu, Dec 13, 2018 at 02:48:59PM +1100, NeilBrown wrote: > > Yes, you could rcu_free the old one and allocate a new one. Then you > would have to be ready to deal with memory allocation failure which > complicates usage (I already don't like that rhashtable_insert() can > report -ENOMEM!). Yes there will be a cost to dealing with allocation failure but at least it'll work reliably in all cases. For the intended use-case of dumping things to user-space allocation failure is a non-issue. > > Now you're conflating two different things. Dropping the RCU > > isn't necessarily slow. We were talking about waiting for an > > RCU grace period which would only come into play if you were > > suspending the walk indefinitely. Actually as I said above even > > there you don't really need to wait. > > How would rhashtable_walk_stop() know if it was indefinite or not? You assume that it's always indefinite because the typical usage of stop is because we have run out of memory and must wait for user- space to read what we have produced so far to free up memory. > *Not* keeping them all in the hash chain is ideal, but not essential. > I see three costs with this. > One is that we would compare the same key multiple times for lookup. > How much of a problem is that? A failing compare is usually quite quick, > and most rhltable uses have inline memcmp for comparison (admittedly not > all). > > The second cost is tracking the chain length against elasticity. > We could flag one object with each key as a 'master' (low bit of the > 'next' pointer) and only count the masters. When lookup raced with > remove this might get a slightly incorrect count, but I don't think that > hurts. > > Finally, there is more pointer chasing as the chains are longer. The biggest problem is that you can no longer return the lookup result. When you perform a lookup on rhltable you need to return all the matching objects, not just a random one. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt