Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16f9530e authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Greg Kroah-Hartman
Browse files

Staging: 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: default avatarSven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 952c699c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
 * 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
+2 −8
Original line number Diff line number Diff line
@@ -418,13 +418,6 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
	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)
+0 −1
Original line number Diff line number Diff line
@@ -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;
};