public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCH 07/15] batman-adv: convert orig_node->vlan_list to hlist
Date: Tue, 25 Aug 2015 13:02:31 +0200	[thread overview]
Message-ID: <1440500559-28368-8-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1440500559-28368-1-git-send-email-antonio@meshcoding.com>

From: Marek Lindner <mareklindner@neomailbox.ch>

Since the list's tail is never accessed using a double linked list head
wastes memory.

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
 net/batman-adv/originator.c        | 7 ++++---
 net/batman-adv/translation-table.c | 8 ++++----
 net/batman-adv/types.h             | 4 ++--
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 4500e3a..610620a 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -26,6 +26,7 @@
 #include <linux/list.h>
 #include <linux/lockdep.h>
 #include <linux/netdevice.h>
+#include <linux/rculist.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
@@ -70,7 +71,7 @@ batadv_orig_node_vlan_get(struct batadv_orig_node *orig_node,
 	struct batadv_orig_node_vlan *vlan = NULL, *tmp;
 
 	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)
 			continue;
 
@@ -118,7 +119,7 @@ batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node,
 	atomic_set(&vlan->refcount, 2);
 	vlan->vid = vid;
 
-	list_add_rcu(&vlan->list, &orig_node->vlan_list);
+	hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list);
 
 out:
 	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,
 		return NULL;
 
 	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);
 	spin_lock_init(&orig_node->bcast_seqno_lock);
 	spin_lock_init(&orig_node->neigh_list_lock);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 3932df2..9e1f866 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -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) {
 		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);
 		batadv_orig_node_vlan_free_ref(vlan);
 	}
@@ -741,7 +741,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,
 	u8 *tt_change_ptr;
 
 	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_entries += atomic_read(&vlan->tt.num_entries);
 	}
@@ -767,7 +767,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node *orig_node,
 	(*tt_data)->num_vlan = htons(num_vlan);
 
 	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->crc = htonl(vlan->tt.crc);
 
@@ -2466,7 +2466,7 @@ static void batadv_tt_global_update_crc(struct batadv_priv *bat_priv,
 
 	/* recompute the global CRC for each VLAN */
 	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
 		 * the CRC as we ignore all the global entries over it
 		 */
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index f2ebe33..fe3695c 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -190,7 +190,7 @@ struct batadv_vlan_tt {
 struct batadv_orig_node_vlan {
 	unsigned short vid;
 	struct batadv_vlan_tt tt;
-	struct list_head list;
+	struct hlist_node list;
 	atomic_t refcount;
 	struct rcu_head rcu;
 };
@@ -302,7 +302,7 @@ struct batadv_orig_node {
 	spinlock_t out_coding_list_lock; /* Protects out_coding_list */
 #endif
 	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 */
 	struct batadv_orig_bat_iv bat_iv;
 };
-- 
2.5.0


  parent reply	other threads:[~2015-08-25 11:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 11:02 [B.A.T.M.A.N.] pull request: batman-adv 20150825 Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 01/15] batman-adv: Replace C99 int types with kernel type Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 02/15] batman-adv: Fix kerneldoc over 80 column lines Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 03/15] batman-adv: Remove multiple assignment per line Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 04/15] batman-adv: update kernel doc of batadv_tt_global_del_orig_entry() Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 05/15] batman-adv: rename batadv_new_tt_req_node to batadv_tt_req_node_new Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 06/15] batman-adv: Remove batadv_ types forward declarations Antonio Quartulli
2015-08-25 11:02 ` Antonio Quartulli [this message]
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 08/15] batman-adv: prevent potential hlist double deletion Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 09/15] batman-adv: Return EINVAL on invalid gw_bandwidth change Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 10/15] batman-adv: Fix gw_bandwidth calculation on 32 bit systems Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 11/15] batman-adv: convert bat_priv->tt.req_list to hlist Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 12/15] batman-adv: Annotate deleting functions with external lock via lockdep Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 13/15] batman-adv: Add lockdep_asserts for documented external locks Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 14/15] batman-adv: Fix conditional statements indentation Antonio Quartulli
2015-08-25 11:02 ` [B.A.T.M.A.N.] [PATCH 15/15] batman-adv: beautify supported routing algorithm list Antonio Quartulli
2015-08-25 23:21 ` [B.A.T.M.A.N.] pull request: batman-adv 20150825 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440500559-28368-8-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox