Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2946992imm; Thu, 24 May 2018 19:39:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo28oTadlRYg1JBsW68nFOSlH+3tOEq/Lxlq2BmGrXKKUEC+E248ZgFv+bK7AwoWXb2PS+g X-Received: by 2002:a62:578e:: with SMTP id i14-v6mr575501pfj.119.1527215982624; Thu, 24 May 2018 19:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527215982; cv=none; d=google.com; s=arc-20160816; b=hfMtUzZwP0yJvZsEZ8gT7TiiY59/T76CRUgp8MqG+3da4oD2/W5pr++0FuVdvhG5eJ XNgfA/mGcTNIzH+lMIRHhnfgbN10/QaErhDln99bOaeq5VYUR9s+Mct0iYUR+r1Qipv9 D4w2fcOdfzMoVGXEHGeLCdSnSy5bon6t9auYVZ7V7RpEGMJEe+sGoFFhgqSPj//tM+4H kc8weFrpPx3cDbpjmy2e227TlIMVpbhG+VDlmYKmWGvtlhUnKooNeIhiReAtQPZGSyyJ fkvAa1oGQYnALAqMXCOvew11/DV8EWX1ZJ8pNR2oEFYvJYxeS5vCXlOMq3Jh/K8Ra5yo 0hhQ== 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=LbAlZhE373hUimoeaKomqRUAkaji4ZxhWRMHoRv+uXE=; b=KqtdAYS+7oJpuAd4OtUmxabXXga1VlQwLZlwdM4iGylYGy/zsrSKiyU9lNR/MjutsP hbPphH7c8MOrxWl3a+efTAtmUf6t7puvtAyKjIcvSaXyGNSV2JIZ0NTcvw+MTzVNieop O5UUcI+FBz3wvp8cHun+6wRo4ehoWyW2vTIv630a8ZWpw4utEflkeplMrYl2TQTuk91D NIaGAFKEv2jfFWNnj/igsLaRRyg9615rPNF6ew8RUH15nK/wQofcDrDpoEPnrA27BV24 tQw8UUP6tw1iYoSnzcr/Y8wGigsodACgzA8LE/9gnCUYAPmxgkr5MNp3JyVa+qcb2BFI Iu5Q== 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 a4-v6si22355984plp.219.2018.05.24.19.39.28; Thu, 24 May 2018 19:39:42 -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 S1034465AbeEXTI1 (ORCPT + 99 others); Thu, 24 May 2018 15:08:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:33743 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030244AbeEXTIY (ORCPT ); Thu, 24 May 2018 15:08:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CBA83AD1E; Thu, 24 May 2018 19:08:22 +0000 (UTC) Date: Thu, 24 May 2018 11:51:55 -0700 From: Davidlohr Bueso To: Linus Torvalds Cc: Thomas Graf , Herbert Xu , Andrew Morton , Manfred Spraul , guillaume.knispel@supersonicimagine.com, Linux API , Linux Kernel Mailing List Subject: Re: semantics of rhashtable and sysvipc Message-ID: <20180524185155.3bx4ujgz5f5g3epi@linux-n805> References: <20180523172500.anfvmjtumww65ief@linux-n805> <20180524170700.wblnybinjzx5rwky@linux-n805> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 May 2018, Linus Torvalds wrote: >This doesn't seem to be taking 'param->min_size' into account. It was in that rounded_hashtable_size() does, however, after more thought I think we can do better by taking it much more into account. > >I'm not sure that matters, but right now, if you have nelem_hint set and a >min_size, the min_size is honored (if you have just min_size it's already >ignored because the rhashtable always starts with HASH_DEFAULT_SIZE). So I >could imagine that somebody uses it to guarantee something. The docs say >that "min_size" is the minimum size for *shrinking* not for initializing, >so I guess it's debatable. > >Also, wouldn't it make sense to make this all be a while loop? Or are you >just depending on the knowledge that HASH_DEFAULT_SIZE / 2 is already >guaranteed to be so small that there's no point? A comment to that effect >would be good, perhaps. Yes, this is why I didn't loop. With the default size of 64 buckets, we allocate 640 + 128 = 768 bytes for the tbl and the lock array, respectively. By halving this, upon retrying, I was relying on it being to "small to fail". However, after how about the resize being based on HASH_MIN_SIZE instead of HASH_DEFAULT_SIZE? That way the initial table would be a _lot_ smaller and aid the allocator that much more; which is why we're here in the first place. Any performance costs of collisions would be completely unimportant in this scenario. Considering that some users set p.min_size to be rather large-ish (up to 1024 buckets afaict), we'd need the following: size = min(ht->p.min_size, HASH_MIN_SIZE); Which takes into account the min_size = max(ht->p.min_size, HASH_MIN_SIZE) which came before, thus p.min_size == 0 is already taken into account. Thanks, Davidlohr