]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Staging: batman-adv: Use synchronize_rcu instead of call_rcu
authorSven Eckelmann <sven.eckelmann@gmx.de>
Sat, 18 Sep 2010 19:01:18 +0000 (21:01 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Sep 2010 23:29:49 +0000 (16:29 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/batman-adv/TODO
drivers/staging/batman-adv/hard-interface.c
drivers/staging/batman-adv/types.h

index 76b2acd2da7321f2a7ed1409b88384c9f923deea..cb6b026333cbab3e25e089e7c65a76a0c0474769 100644 (file)
@@ -1,7 +1,6 @@
  * Rework usage of RCU
     - don't leak pointers from rcu out of rcu critical area which may
       get freed
-    - check were synchronize_rcu must be used
     - go through Documentation/RCU/checklist.txt
  * Request a new review
  * Process the comments from the review
index 35b198c6bad5c5648b1a942defb8403012c88e40..376ac488bf51dfdef1365b95538bfe630e47dec1 100644 (file)
@@ -418,13 +418,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 */
@@ -438,9 +431,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)
index 478277f6ad08b4c6d6dc36f7c8a115535e4d9030..b16264441ea226566d47d75c29c21892d0a175d2 100644 (file)
@@ -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;
 };