Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At the risk of looking like a reputation whore, let me summarize the answers I've acquired so far.</p> <hr> <h2>Kernel 3.7+</h2> <p>A generic implementation was <a href="http://lwn.net/Articles/510202/" rel="nofollow noreferrer">introduced</a> by Sasha Levin in 2012 and <a href="http://lxr.free-electrons.com/source/include/linux/hashtable.h?v=3.7" rel="nofollow noreferrer">merged</a> for the 3.7 kernel.</p> <hr> <h2>Older Kernels</h2> <p>The kernel (as of 2.6.38) does not include a generic hash table implementation, but does include some pieces:</p> <ul> <li><code>hlist_*/HLIST_*</code> in <a href="http://lxr.linux.no/#linux+v2.6.38/include/linux/list.h#L564" rel="nofollow noreferrer" title="list.h">list.h</a> are single-pointer-head doubly-linked list structs and macros useful for hash buckets. (<a href="https://stackoverflow.com/questions/5489025/hash-table-in-linux-kernel/5503509#5503509">answer below</a> from <a href="https://stackoverflow.com/users/363662/adobriyan">adobriyan</a>)</li> <li><a href="http://lxr.linux.no/#linux+v2.6.38/include/linux/hash.h" rel="nofollow noreferrer">hash.h</a> includes hashing routines for ints, longs, and pointers. <a href="http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf" rel="nofollow noreferrer">This article</a> by Chuck Lever studies the performance of these routines.</li> <li>See <code>pid_hash</code> in <a href="http://lxr.linux.no/#linux+v2.6.38/kernel/pid.c" rel="nofollow noreferrer">pid.c</a> for an example constructed from these primitives.</li> </ul> <p><a href="http://uthash.sourceforge.net/" rel="nofollow noreferrer">uthash</a> is a generic hash table for C implemented as macros defined in a single header file. This solution may be appropriate for many third-party kernel modules (e.g., device drivers). However, reliance on <code>uthash</code> might impede mainlining of a module.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload