diff options
author | Andrew Morton <akpm@osdl.org> | 2004-06-23 18:50:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-06-23 18:50:18 -0700 |
commit | 8c1ce9d6d628945ff23f844dbe9f21f5d5383b99 (patch) | |
tree | 030e150c11f9a3252fd7a1d0c36bd6912ff9eada /security | |
parent | b659a6fbb927a79acd606c4466d03cb615879f9f (diff) | |
download | history-8c1ce9d6d628945ff23f844dbe9f21f5d5383b99.tar.gz |
[PATCH] rcu: avoid passing an argument to the callback function
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: Dipankar Sarma <dipankar@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security')
-rw-r--r-- | security/selinux/netif.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/security/selinux/netif.c b/security/selinux/netif.c index 4cbf8f259d93be..d23bd7e6345e5d 100644 --- a/security/selinux/netif.c +++ b/security/selinux/netif.c @@ -134,9 +134,9 @@ out: return netif; } -static void sel_netif_free(void *p) +static void sel_netif_free(struct rcu_head *p) { - struct sel_netif *netif = p; + struct sel_netif *netif = container_of(p, struct sel_netif, rcu_head); DEBUGP("%s: %s\n", __FUNCTION__, netif->nsec.dev->name); kfree(netif); @@ -151,7 +151,7 @@ static void sel_netif_destroy(struct sel_netif *netif) sel_netif_total--; spin_unlock_bh(&sel_netif_lock); - call_rcu(&netif->rcu_head, sel_netif_free, netif); + call_rcu(&netif->rcu_head, sel_netif_free); } void sel_netif_put(struct sel_netif *netif) |