b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes
@ 2017-11-19 16:59 Sven Eckelmann
  2017-12-06 10:43 ` Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2017-11-19 16:59 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Denys Vlasenko, Sven Eckelmann

From: Denys Vlasenko <dvlasenk@redhat.com>

This function compiles to 288 bytes of machine code for Linux 4.14 on
Debian Stretch amd64 and (6.3.0-18) with the default configuration. 27
callsites (25 used in default config).

   text    data     bss     dec     hex filename
 179291   10317    4416  194024   2f5e8 batman-adv.ko.pre
 171952   10317    4416  186685   2d93d batman-adv.ko.post

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
[sven@narfation.org: Fix includes, correct sizes+counts in commit message]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v3:
 - updated the statistics against Linux 4.14
v2:
 - fixed includes
 - updated statistics for Debian's 4.6.0-1-amd64
 - extended commit message
v1:
 - initial version from Denys Vlasenko

Comparison was done using Linux 4.14 on Debian Stretch on amd64

    make defconfig
    cat >> .config << EOF
    CONFIG_BATMAN_ADV=m
    CONFIG_BATMAN_ADV_BATMAN_V=y
    CONFIG_BATMAN_ADV_BLA=y
    CONFIG_BATMAN_ADV_DAT=y
    CONFIG_BATMAN_ADV_NC=y
    CONFIG_BATMAN_ADV_MCAST=y
    CONFIG_BATMAN_ADV_DEBUGFS=y
    CONFIG_BATMAN_ADV_DEBUG=y
    EOF
    make olddefconfig
    make -j9

My tests with some MIPS based acesspoints didn't show any performance
reductions. https://patchwork.open-mesh.org/patch/15968/
---
 net/batman-adv/originator.c | 32 ++++++++++++++++++++++++++++++++
 net/batman-adv/originator.h | 37 ++-----------------------------------
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 4018ecba..beb168b1 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -33,10 +33,12 @@
 #include <linux/netdevice.h>
 #include <linux/netlink.h>
 #include <linux/rculist.h>
+#include <linux/rcupdate.h>
 #include <linux/seq_file.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/stddef.h>
 #include <linux/workqueue.h>
 #include <net/sock.h>
 #include <uapi/linux/batman_adv.h>
@@ -58,6 +60,36 @@
 /* hash class keys */
 static struct lock_class_key batadv_orig_hash_lock_class_key;
 
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
+{
+	struct batadv_hashtable *hash = bat_priv->orig_hash;
+	struct hlist_head *head;
+	struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
+	int index;
+
+	if (!hash)
+		return NULL;
+
+	index = batadv_choose_orig(data, hash->size);
+	head = &hash->table[index];
+
+	rcu_read_lock();
+	hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
+		if (!batadv_compare_eth(orig_node, data))
+			continue;
+
+		if (!kref_get_unless_zero(&orig_node->refcount))
+			continue;
+
+		orig_node_tmp = orig_node;
+		break;
+	}
+	rcu_read_unlock();
+
+	return orig_node_tmp;
+}
+
 static void batadv_purge_orig(struct work_struct *work);
 
 /**
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index 220c12f2..0e0a12e6 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -26,14 +26,8 @@
 #include <linux/compiler.h>
 #include <linux/if_ether.h>
 #include <linux/jhash.h>
-#include <linux/kref.h>
-#include <linux/rculist.h>
-#include <linux/rcupdate.h>
-#include <linux/stddef.h>
 #include <linux/types.h>
 
-#include "hash.h"
-
 struct netlink_callback;
 struct seq_file;
 struct sk_buff;
@@ -103,34 +97,7 @@ static inline u32 batadv_choose_orig(const void *data, u32 size)
 	return hash % size;
 }
 
-static inline struct batadv_orig_node *
-batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
-{
-	struct batadv_hashtable *hash = bat_priv->orig_hash;
-	struct hlist_head *head;
-	struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
-	int index;
-
-	if (!hash)
-		return NULL;
-
-	index = batadv_choose_orig(data, hash->size);
-	head = &hash->table[index];
-
-	rcu_read_lock();
-	hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
-		if (!batadv_compare_eth(orig_node, data))
-			continue;
-
-		if (!kref_get_unless_zero(&orig_node->refcount))
-			continue;
-
-		orig_node_tmp = orig_node;
-		break;
-	}
-	rcu_read_unlock();
-
-	return orig_node_tmp;
-}
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
 
 #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes
  2017-11-19 16:59 [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes Sven Eckelmann
@ 2017-12-06 10:43 ` Sven Eckelmann
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2017-12-06 10:43 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Denys Vlasenko

[-- Attachment #1: Type: text/plain, Size: 863 bytes --]

On Sonntag, 19. November 2017 17:59:13 CET Sven Eckelmann wrote:
> From: Denys Vlasenko <dvlasenk@redhat.com>
> 
> This function compiles to 288 bytes of machine code for Linux 4.14 on
> Debian Stretch amd64 and (6.3.0-18) with the default configuration. 27
> callsites (25 used in default config).
> 
>    text    data     bss     dec     hex filename
>  179291   10317    4416  194024   2f5e8 batman-adv.ko.pre
>  171952   10317    4416  186685   2d93d batman-adv.ko.post
> 
> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
> [sven@narfation.org: Fix includes, correct sizes+counts in commit message]
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> v3:
>  - updated the statistics against Linux 4.14

Applied in f795e77ba40d [1]

Kind regards,
	Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/f795e77ba40d104a6a20f5706b88fae1671dd1a5

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-06 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-19 16:59 [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes Sven Eckelmann
2017-12-06 10:43 ` Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).