• David Howells's avatar
    rxrpc: Add a common object cache · 7c02dc94
    David Howells authored
    Add a common object cache implementation for RxRPC.  This will be used to
    cache objects of various types (calls, connections, local and remote
    endpoint records).  Each object that would be cached must contain an
    obj_node struct for the cache to use.  The object's usage count and link
    pointers are here, plus other internal metadata.
    
    Each object cache consists of a primary hash to which all objects of that
    type must be added and a secondary hash to which objects may also be added
    and removed a single time.  Objects are automatically removed from both
    hashes when they expire.
    
    Objects start off life with a usage count of 2 - one for the cache and one
    for the caller.  When an object's usage count is reduced to 1, it sits in
    the cache until its expiry time is reached, at which point the cache
    attempts to reduce the count to 0 and, if successful, clean it up.  An
    object with a usage count of 1 in the cache can be looked up and have its
    usage count increased, thereby stopping the expiry process.
    
    Objects are looked up, unlinked and destroyed under RCU-safe conditions.
    
    A garbage collector cycles through all the hash buckets in the primary hash
    and compares the expiry times of the usage-count-1 objects to the current
    time, removing any that have expired.  This is kicked by a single timer for
    the whole cache rather than having a timer per object.
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    7c02dc94
Makefile 455 Bytes