• Herbert Xu's avatar
    rhashtable: Allow hash/comparison functions to be inlined · 02fd97c3
    Herbert Xu authored
    This patch deals with the complaint that we make indirect function
    calls on the fast paths unnecessarily in rhashtable.  We resolve
    it by moving the fast paths into inline functions that take struct
    rhashtable_param (which obviously must be the same set of parameters
    supplied to rhashtable_init) as an argument.
    
    The only remaining indirect call is to obj_hashfn (or key_hashfn it
    obj_hashfn is unset) on the rehash as well as the insert-during-
    rehash slow path.
    
    This patch also extends the support of vairable-length keys to
    include those where the key is fixed but scattered in the object.
    For example, in netlink we want to key off the namespace and the
    portid but they're not next to each other.
    
    This patch does this by directly using the object hash function
    as the indicator of whether the key is accessible or not.  It
    also adds a new function obj_cmpfn to compare a key against an
    object.  This means that the caller no longer needs to supply
    explicit compare functions.
    
    All this is done in a backwards compatible manner so no existing
    users are affected until they convert to the new interface.
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    02fd97c3
rhashtable.h 23 KB