The following commit has been merged in the next branch: commit 553d0da3361c4df3d0a1de20f356a97cf9a9197b Author: Sven Eckelmann sven.eckelmann@gmx.de Date: Sat Sep 18 15:35:40 2010 +0000
batman-adv: Use synchronize_rcu instead of call_rcu
It is recommended [1] to use synchronize_rcu to simplify the code - especially when otherwise extra locking is needed to protect other code from picking stale elements. It also protects us for emitting to many callbacks which may results in OOM conditions.
The only reason not to use it, would be in performance critical sections or when we are not allowed to block.
[1] Documentation/RCU/checklist.txt
Signed-off-by: Sven Eckelmann sven.eckelmann@gmx.de
diff --git a/hard-interface.c b/hard-interface.c index 3cd7cb1..0b3ee6b 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -420,13 +420,6 @@ out: return NULL; }
-static void hardif_free_interface(struct rcu_head *rcu) -{ - struct batman_if *batman_if = container_of(rcu, struct batman_if, rcu); - - kfree(batman_if); -} - static void hardif_remove_interface(struct batman_if *batman_if) { /* first deactivate interface */ @@ -440,9 +433,10 @@ static void hardif_remove_interface(struct batman_if *batman_if)
/* caller must take if_list_lock */ list_del_rcu(&batman_if->list); + synchronize_rcu(); sysfs_del_hardif(&batman_if->hardif_obj); dev_put(batman_if->net_dev); - call_rcu(&batman_if->rcu, hardif_free_interface); + kfree(batman_if); }
void hardif_remove_interfaces(void) diff --git a/types.h b/types.h index 478277f..b162644 100644 --- a/types.h +++ b/types.h @@ -44,7 +44,6 @@ struct batman_if { unsigned char *packet_buff; int packet_len; struct kobject *hardif_obj; - struct rcu_head rcu; struct packet_type batman_adv_ptype; struct net_device *soft_iface; };