Skip to contentSkip to conversation

batman-adv: use kmem_cache for translation table

RFC Superseded Sven Eckelmann 2 participants 3 messages May 15, 2016 – Jun 25, 2016 Batman advanced

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sven Eckelmann

author maintainer
#0 lore raw

RFC 1/1 batman-adv: use kmem_cache for translation table

The two translation tables (global, local) contain equally sized objects. The global translation table changes often when a client is connected/removed from the mesh. So it makes sense to keep a cache of the equally sized objects.

TODO statistics, batadv_tt_roam_node?, batadv_tt_change_node?, batadv_tt_req_node?, ....

---
 net/batman-adv/main.c              |  16 +++++-
 net/batman-adv/translation-table.c | 115 ++++++++++++++++++++++++++++++++++---
 net/batman-adv/translation-table.h |   3 +
 3 files changed, 125 insertions(+), 9 deletions(-)
net/batman-adv/main.c +14 -2
index 275604b..1c546d9 100644
@@ -81,6 +81,12 @@ static void batadv_recv_handler_init(void);
 
 static int __init batadv_init(void)
 {
+	int ret;
+
+	ret = batadv_tt_cache_init();
+	if (ret < 0)
+		return ret;
+
 	INIT_LIST_HEAD(&batadv_hardif_list);
 	batadv_algo_init();
 
@@ -91,9 +97,8 @@ static int __init batadv_init(void)
 	batadv_nc_init();
 
 	batadv_event_workqueue = create_singlethread_workqueue("bat_events");
-
 	if (!batadv_event_workqueue)
-		return -ENOMEM;
+		goto err_create_wq;
 
 	batadv_socket_init();
 	batadv_debugfs_init();
@@ -106,6 +111,11 @@ static int __init batadv_init(void)
 		BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
 
 	return 0;
+
+err_create_wq:
+	batadv_tt_cache_destroy();
+
+	return -ENOMEM;
 }
 
 static void __exit batadv_exit(void)
@@ -121,6 +131,8 @@ static void __exit batadv_exit(void)
 	batadv_event_workqueue = NULL;
 
 	rcu_barrier();
+
+	batadv_tt_cache_destroy();
 }
 
 int batadv_mesh_init(struct net_device *soft_iface)
net/batman-adv/translation-table.c +108 -7

202 lines not on this page · raw message

net/batman-adv/translation-table.h +3 -0
index 7c7e2c0..02b0f85 100644
@@ -59,4 +59,7 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
 bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
 				  const u8 *addr, unsigned short vid);
 
+int batadv_tt_cache_init(void);
+void batadv_tt_cache_destroy(void);
+
 #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
Signature · 1 line
2.8.1
#1 lore raw
Quoted 2 lines · Sven Eckelmann

TODO statistics, batadv_tt_roam_node?, batadv_tt_change_node?, batadv_tt_req_node?, ....

Some statistics here:

https://www.open-mesh.org/projects/batman-adv/wiki/Kmalloc-kmem-cache-tests

In a nutshell, on a small TP-Link TL-841NDv8 wireless router (MIPS/AR9341), I was able to achieve 34% more global TT entries (or 25% less RAM usage).

Regarding SLAB_HWCACHE_ALIGN, it did not seem to make much of a difference. There is a slight tendency for less RAM usage without this flag. But it is so small, that it might be a coincident, too. And it is definitely negligable. At least for this architecture.

Regards, Linus

PS: I might make some more, pretty graphs for the other test variables, too. But for now, there is just this one raw table for that.

author maintainer
#2 lore raw

On Monday 20 June 2016 03:59:01 Linus Lüssing wrote:
[...]

Quoted 6 lines

https://www.open-mesh.org/projects/batman-adv/wiki/Kmalloc-kmem-cache-tests

In a nutshell, on a small TP-Link TL-841NDv8 wireless router (MIPS/AR9341), I was able to achieve 34% more global TT entries (or 25% less RAM usage).

[...]

Really interesting. I wouldn't have expected that kind of difference. So your ideas really seemed to have worked :)

I have submitted an actual patch [1]. Do you know when it is planned to have your nofdb changes [2] merged in gluon?

Kind regards,
Sven

[1] https://patchwork.open-mesh.org/patch/16392/
[2] https://github.com/freifunk-gluon/gluon/pull/780