• Andrew Morton's avatar
    [PATCH] rcu: avoid passing an argument to the callback function · 8c1ce9d6
    Andrew Morton authored
    From: Dipankar Sarma <dipankar@in.ibm.com>
    
    This patch changes the call_rcu() API and avoids passing an argument to the
    callback function as suggested by Rusty.  Instead, it is assumed that the
    user has embedded the rcu head into a structure that is useful in the
    callback and the rcu_head pointer is passed to the callback.  The callback
    can use container_of() to get the pointer to its structure and work with
    it.  Together with the rcu-singly-link patch, it reduces the rcu_head size
    by 50%.  Considering that we use these in things like struct dentry and
    struct dst_entry, this is good savings in space.
    
    An example :
    
    struct my_struct {
    	struct rcu_head rcu;
    	int x;
    	int y;
    };
    
    void my_rcu_callback(struct rcu_head *head)
    {
    	struct my_struct *p = container_of(head, struct my_struct, rcu);
    	free(p);
    }
    
    void my_delete(struct my_struct *p)
    {
    	...
    	call_rcu(&p->rcu, my_rcu_callback);
    	...
    }
    Signed-Off-By: default avatarDipankar Sarma <dipankar@in.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    8c1ce9d6
util.c 12.4 KB