STRUCT RHASHTABLE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct rhashtable(9) πŸ’–

okay bestie, welcome to the Kernel API Manual β€” today's main character is struct rhashtable, aka the hash table handle, and honestly? she's iconic. let's get into it 🫢


✨ NAME ✨

struct rhashtable β€” Hash table handle πŸ’…


🌸 SYNOPSIS 🌸

struct rhashtable {
    struct bucket_table *tbl;
    unsigned int                    key_len;
    unsigned int                    max_elems;
    struct rhashtable_params        p;
    bool rhlist;
    struct work_struct              run_work;
    struct irq_work                 run_irq_work;
    struct mutex                    mutex;
    spinlock_t lock;
    atomic_t nelems;
  #ifdef CONFIG_MEM_ALLOC_PROFILING;
    struct alloc_tag                *alloc_tag;
  #endif;
 };

no cap, that's the whole vibe right there ⬆️


πŸ‘‘ Members πŸ‘‘

every field gets her moment, periodt:

  • tbl β€” Bucket table πŸͺ£ (yes literally, that's the table of buckets, she's the whole point)
  • key_len β€” Key length for hashfn πŸ”‘ (how long your keys are, for the hash function's purposes)
  • max_elems β€” Maximum number of elements in table πŸ“ (the ceiling, the limit, the "we're full bestie" number)
  • p β€” Configuration parameters βš™οΈ (all the setup details live here)
  • rhlist β€” True if this is an rhltable πŸ’€ (like, bool true. it's an rhltable. that's the whole note)
  • run_work β€” Deferred worker to expand/shrink asynchronously 🧚 (does the growing and shrinking later, in the background, no blocking)
  • run_irq_work β€” Bounces the run_work kick through hard IRQ context. ⚑ (it relays the kick over to run_work by way of hard IRQ context, iykyk)
  • mutex β€” Mutex to protect current/future table swapping πŸ”’ (guard duty for the table swapping, now and later)
  • lock β€” Spin lock to protect walker list πŸŒ€ (keeps the walker list safe)
  • nelems β€” Number of elements in table πŸ”’ (how many are actually in there rn)
not me getting emotional over a struct with this many locks in it 😭 she's doing the most and we love her for it

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./include/linux/rhashtable-types.h
  • struct rhashtable_compare_arg(9)
  • struct rhashtable_params(9)
  • struct rhltable(9)
  • struct rhashtable_walker(9)
  • struct rhashtable_iter(9)

go read the whole friend group, they're all slay 🌈


and that's the tea, bestie πŸŽ€ this was brought to you from ./include/linux, October 2026 edition β€” mwah, ily, go touch some kernel code βœ¨πŸ’œ

πŸ“¦ where this page comes from