From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 16 19:19:24 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 813CAB4F for ; Mon, 16 Mar 2015 19:19:24 +0000 (UTC) Received: from mail-pa0-x22b.google.com (mail-pa0-x22b.google.com [IPv6:2607:f8b0:400e:c03::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 505B45E0 for ; Mon, 16 Mar 2015 19:19:24 +0000 (UTC) Received: by pagr17 with SMTP id r17so73230188pag.0 for ; Mon, 16 Mar 2015 12:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=WKnWdQeghNDeh5+M1bAfPS8Own8+d+ioRxYQjcnLFt0=; b=PPqnB6/x2mf5DvyonENn9TMKeJ1Npzi6DaMWeM03ELkPiwjWe8qCg0CPDq0SrVU1iQ rnh1AFzPYZ8eXAher4IMuS8KNa9Z4Pjfk4PDTuuitrR6vE9OsjqC7gAJtdO9f+OuRi2+ 2Vy1AfFhLR4wEpCf4KAab3kqRi6hg78UOMGqFcAXa7CE1iYwqOwnbdXmjZHFJBBl++Rx MOkR0tFydq4bNHkX80lepT+GbxrnK7h0pz5FQOhBjwEnSum4Y1Gsa6mfR/DE4I3xkzsP jJ5UhBvu23FZm/zerUJM9Dc8m5isRtPQtBOUaUTTsBiEfRQS8hr3gDeOobs+kWjaQjLF RN/Q== X-Received: by 10.66.234.2 with SMTP id ua2mr119359938pac.137.1426533563819; Mon, 16 Mar 2015 12:19:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.179.203 with HTTP; Mon, 16 Mar 2015 12:18:53 -0700 (PDT) From: Yue Chen Date: Mon, 16 Mar 2015 15:18:53 -0400 Message-ID: Subject: Hash table in FreeBSD kernel? To: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2015 19:19:24 -0000 Dear all, Is there a good hash table implementation for FreeBSD kernel, x86_64? I tried "uthash", but encountered some memory problems (during HASH_FIND()) when the entry number becomes large. The cause may be my replacements for the user-space header functions and types are incorrect. ===================================================================== The userland functions/types need to be replaced: #include /* memcmp,strlen */ #include /* ptrdiff_t */ #include /* exit() */ /* malloc() */ ===================================================================== I use: #include /* memcmp */ #include typedef __ptrdiff_t ptrdiff_t; #include #include /* the malloc() */ ------------------------------------------------------------------------------------------------------------------------ size_t strlen(const char *str) { const char *s; for (s = str; *s; ++s); return(s - str); } ===================================================================== Any suggestions for using "uthash" in kernel, or any other alternatives that I can use? (the FreeBSD kernel's "hash32" function set seems only support 32-bit key hash) Best regards and thanks, Yue