From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8qtP-0005B7-0x for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:20:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8qtJ-0008AS-1c for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:20:09 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:33186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8qtI-0008AL-Pf for qemu-devel@nongnu.org; Fri, 03 Jun 2016 11:20:04 -0400 Received: by mail-lf0-x232.google.com with SMTP id s64so56753857lfe.0 for ; Fri, 03 Jun 2016 08:20:04 -0700 (PDT) References: <1464138802-23503-1-git-send-email-cota@braap.org> <1464138802-23503-11-git-send-email-cota@braap.org> <574B487B.5080200@gmail.com> <20160603091828.GA5251@flamenco> From: Sergey Fedorov Message-ID: <5751A010.1000400@gmail.com> Date: Fri, 3 Jun 2016 18:19:44 +0300 MIME-Version: 1.0 In-Reply-To: <20160603091828.GA5251@flamenco> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: QEMU Developers , MTTCG Devel , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini , Richard Henderson On 03/06/16 12:18, Emilio G. Cota wrote: > On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote: >> I was just wondering if it could be worthwhile to pass a hash function >> when initializing a QHT. Then we could have variants of qht_insert(), >> qht_remove() and qht_lookup() which does not require a computed hash >> value but call the function by themselves. This could make sense since a >> hash value passed the the functions should always be exactly the same >> for the same object. > I considered this when designing the API. I think it's not worth having > in qht; callers could have their own wrapper to do this though. > > For the only caller of qht that we have so far I don't see this > as being worth the hassle. > > For instance, we couldn't use the same function for lookups and > inserts/removals, since the hash function would look like: > > uint32_t hash_func(void *p) > { > TranslationBlock *tb = p; > return tb_hash_func(tb->phys_pc, ...); > } > > But for lookups we don't yet know *tb (that's what we're looking for!). > All we have is the tb_desc struct that we use for comparisons. Fair enough. Thanks, Sergey