batman-adv: Initialize lockdep class keys for hashes

Message ID 1352541632-25336-1-git-send-email-ordex@autistici.org (mailing list archive)
State Accepted, archived
Commit 6ca1b358381e5dc199cd1f8bc739c71fa6a486ca
Headers

Commit Message

Antonio Quartulli Nov. 10, 2012, 10 a.m. UTC
  Different hashes have the same class key key because they get
initialised with the same one. For this reason lockdep can create
false warning when they are used recursively.

Re-initialise the key for each hash after the invocation to hash_new()
to avoid this problem.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 originator.c        |  6 ++++++
 translation-table.c | 10 ++++++++++
 vis.c               |  6 ++++++
 3 files changed, 22 insertions(+)
  

Comments

Antonio Quartulli Nov. 13, 2012, 8:06 a.m. UTC | #1
On Sat, Nov 10, 2012 at 11:00:32AM +0100, Antonio Quartulli wrote:
> Different hashes have the same class key key because they get
> initialised with the same one. For this reason lockdep can create
> false warning when they are used recursively.
> 
> Re-initialise the key for each hash after the invocation to hash_new()
> to avoid this problem.
> 
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>

I was thinking...instead of creating such "a free noise" in udev, we may want to
add a configuration facility so that the user can choose which uevents to enable
and which not..

If we don't do so batman-adv will start throwing uevents even if not needed.

Please, drop this patch. We need some more code here :-)

Cheers,
  
Antonio Quartulli Nov. 13, 2012, 8:08 a.m. UTC | #2
On Tue, Nov 13, 2012 at 09:06:22AM +0100, Antonio Quartulli wrote:
> On Sat, Nov 10, 2012 at 11:00:32AM +0100, Antonio Quartulli wrote:
> > Different hashes have the same class key key because they get
> > initialised with the same one. For this reason lockdep can create
> > false warning when they are used recursively.
> > 
> > Re-initialise the key for each hash after the invocation to hash_new()
> > to avoid this problem.
> > 
> > Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> 
> I was thinking...instead of creating such "a free noise" in udev, we may want to
> add a configuration facility so that the user can choose which uevents to enable
> and which not..
> 
> If we don't do so batman-adv will start throwing uevents even if not needed.
> 
> Please, drop this patch. We need some more code here :-)

Sorry, the message above was meant for another patch -.-
  
Linus Lüssing Dec. 1, 2012, 10:46 a.m. UTC | #3
Tested-by: Linus Lüssing <linus.luessing@web.de>
  
Marek Lindner Dec. 1, 2012, 1:11 p.m. UTC | #4
On Saturday, December 01, 2012 18:46:33 Linus Lüssing wrote:
> Tested-by: Linus Lüssing <linus.luessing@web.de>

Applied in revision 6ca1b35.

Thanks,
Marek
  

Patch

diff --git a/originator.c b/originator.c
index 8c32cf1..109081c 100644
--- a/originator.c
+++ b/originator.c
@@ -29,6 +29,9 @@ 
 #include "soft-interface.h"
 #include "bridge_loop_avoidance.h"
 
+/* hash class keys */
+static struct lock_class_key batadv_orig_hash_lock_class_key;
+
 static void batadv_purge_orig(struct work_struct *work);
 
 static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
@@ -57,6 +60,9 @@  int batadv_originator_init(struct batadv_priv *bat_priv)
 	if (!bat_priv->orig_hash)
 		goto err;
 
+	batadv_hash_set_lock_class(bat_priv->orig_hash,
+				   &batadv_orig_hash_lock_class_key);
+
 	batadv_start_purge_timer(bat_priv);
 	return 0;
 
diff --git a/translation-table.c b/translation-table.c
index 4657d9e..1bcb705 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -29,6 +29,10 @@ 
 
 #include <linux/crc16.h>
 
+/* hash class keys */
+static struct lock_class_key batadv_tt_local_hash_lock_class_key;
+static struct lock_class_key batadv_tt_global_hash_lock_class_key;
+
 static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
 				 struct batadv_orig_node *orig_node);
 static void batadv_tt_purge(struct work_struct *work);
@@ -235,6 +239,9 @@  static int batadv_tt_local_init(struct batadv_priv *bat_priv)
 	if (!bat_priv->tt.local_hash)
 		return -ENOMEM;
 
+	batadv_hash_set_lock_class(bat_priv->tt.local_hash,
+				   &batadv_tt_local_hash_lock_class_key);
+
 	return 0;
 }
 
@@ -691,6 +698,9 @@  static int batadv_tt_global_init(struct batadv_priv *bat_priv)
 	if (!bat_priv->tt.global_hash)
 		return -ENOMEM;
 
+	batadv_hash_set_lock_class(bat_priv->tt.global_hash,
+				   &batadv_tt_global_hash_lock_class_key);
+
 	return 0;
 }
 
diff --git a/vis.c b/vis.c
index 0f65a9d..60eb9b7 100644
--- a/vis.c
+++ b/vis.c
@@ -28,6 +28,9 @@ 
 
 #define BATADV_MAX_VIS_PACKET_SIZE 1000
 
+/* hash class keys */
+static struct lock_class_key batadv_vis_hash_lock_class_key;
+
 static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
 
 /* free the info */
@@ -852,6 +855,9 @@  int batadv_vis_init(struct batadv_priv *bat_priv)
 		goto err;
 	}
 
+	batadv_hash_set_lock_class(bat_priv->vis.hash,
+				   &batadv_vis_hash_lock_class_key);
+
 	bat_priv->vis.my_info = kmalloc(BATADV_MAX_VIS_PACKET_SIZE, GFP_ATOMIC);
 	if (!bat_priv->vis.my_info)
 		goto err;