Commit d0fa4f3f authored by Marek Lindner's avatar Marek Lindner Committed by Antonio Quartulli

batman-adv: convert orig_node->vlan_list to hlist

Since the list's tail is never accessed using a double linked list head
wastes memory.
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarAntonio Quartulli <antonio@meshcoding.com>
parent 2bdd1888
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/lockdep.h> #include <linux/lockdep.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/rculist.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -70,7 +71,7 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node, ...@@ -70,7 +71,7 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
struct batadv_orig_node_vlan *vlan = NULL, *tmp; struct batadv_orig_node_vlan *vlan = NULL, *tmp;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) { hlist_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) {
if (tmp->vid != vid) if (tmp->vid != vid)
continue; continue;
...@@ -118,7 +119,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, ...@@ -118,7 +119,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
atomic_set(&vlan->refcount, 2); atomic_set(&vlan->refcount, 2);
vlan->vid = vid; vlan->vid = vid;
list_add_rcu(&vlan->list, &orig_node->vlan_list); hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list);
out: out:
spin_unlock_bh(&orig_node->vlan_list_lock); spin_unlock_bh(&orig_node->vlan_list_lock);
...@@ -673,7 +674,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, ...@@ -673,7 +674,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
return NULL; return NULL;
INIT_HLIST_HEAD(&orig_node->neigh_list); INIT_HLIST_HEAD(&orig_node->neigh_list);
INIT_LIST_HEAD(&orig_node->vlan_list); INIT_HLIST_HEAD(&orig_node->vlan_list);
INIT_HLIST_HEAD(&orig_node->ifinfo_list); INIT_HLIST_HEAD(&orig_node->ifinfo_list);
spin_lock_init(&orig_node->bcast_seqno_lock); spin_lock_init(&orig_node->bcast_seqno_lock);
spin_lock_init(&orig_node->neigh_list_lock); spin_lock_init(&orig_node->neigh_list_lock);
......
...@@ -315,7 +315,7 @@ static void batadv_tt_global_size_mod(struct batadv_orig_node *orig_node, ...@@ -315,7 +315,7 @@ static void batadv_tt_global_size_mod(struct batadv_orig_node *orig_node,
if (atomic_add_return(v, &vlan->tt.num_entries) == 0) { if (atomic_add_return(v, &vlan->tt.num_entries) == 0) {
spin_lock_bh(&orig_node->vlan_list_lock); spin_lock_bh(&orig_node->vlan_list_lock);
list_del_rcu(&vlan->list); hlist_del_rcu(&vlan->list);
spin_unlock_bh(&orig_node->vlan_list_lock); spin_unlock_bh(&orig_node->vlan_list_lock);
batadv_orig_node_vlan_free_ref(vlan); batadv_orig_node_vlan_free_ref(vlan);
} }
...@@ -741,7 +741,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, ...@@ -741,7 +741,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,
u8 *tt_change_ptr; u8 *tt_change_ptr;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) {
num_vlan++; num_vlan++;
num_entries += atomic_read(&vlan->tt.num_entries); num_entries += atomic_read(&vlan->tt.num_entries);
} }
...@@ -767,7 +767,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node, ...@@ -767,7 +767,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,
(*tt_data)->num_vlan = htons(num_vlan); (*tt_data)->num_vlan = htons(num_vlan);
tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1); tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1);
list_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) {
tt_vlan->vid = htons(vlan->vid); tt_vlan->vid = htons(vlan->vid);
tt_vlan->crc = htonl(vlan->tt.crc); tt_vlan->crc = htonl(vlan->tt.crc);
...@@ -2466,7 +2466,7 @@ static void batadv_tt_global_update_crc(struct batadv_priv *bat_priv, ...@@ -2466,7 +2466,7 @@ static void batadv_tt_global_update_crc(struct batadv_priv *bat_priv,
/* recompute the global CRC for each VLAN */ /* recompute the global CRC for each VLAN */
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) { hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) {
/* if orig_node is a backbone node for this VLAN, don't compute /* if orig_node is a backbone node for this VLAN, don't compute
* the CRC as we ignore all the global entries over it * the CRC as we ignore all the global entries over it
*/ */
......
...@@ -190,7 +190,7 @@ struct batadv_vlan_tt { ...@@ -190,7 +190,7 @@ struct batadv_vlan_tt {
struct batadv_orig_node_vlan { struct batadv_orig_node_vlan {
unsigned short vid; unsigned short vid;
struct batadv_vlan_tt tt; struct batadv_vlan_tt tt;
struct list_head list; struct hlist_node list;
atomic_t refcount; atomic_t refcount;
struct rcu_head rcu; struct rcu_head rcu;
}; };
...@@ -302,7 +302,7 @@ struct batadv_orig_node { ...@@ -302,7 +302,7 @@ struct batadv_orig_node {
spinlock_t out_coding_list_lock; /* Protects out_coding_list */ spinlock_t out_coding_list_lock; /* Protects out_coding_list */
#endif #endif
struct batadv_frag_table_entry fragments[BATADV_FRAG_BUFFER_COUNT]; struct batadv_frag_table_entry fragments[BATADV_FRAG_BUFFER_COUNT];
struct list_head vlan_list; struct hlist_head vlan_list;
spinlock_t vlan_list_lock; /* protects vlan_list */ spinlock_t vlan_list_lock; /* protects vlan_list */
struct batadv_orig_bat_iv bat_iv; struct batadv_orig_bat_iv bat_iv;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment