netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH 02/19] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes
Date: Wed, 20 Dec 2017 12:01:07 +0100	[thread overview]
Message-ID: <20171220110124.13117-3-sw@simonwunderlich.de> (raw)
In-Reply-To: <20171220110124.13117-1-sw@simonwunderlich.de>

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>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 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 2967b86c13da..0a565d0422bb 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -30,10 +30,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>
@@ -55,6 +57,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 d94220a6d21a..40c7f039d5d7 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -23,14 +23,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;
@@ -100,34 +94,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

  parent reply	other threads:[~2017-12-20 11:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 11:01 [PATCH 00/19] pull request for net-next: batman-adv 2017-12-20 Simon Wunderlich
2017-12-20 11:01 ` [PATCH 01/19] batman-adv: Start new development cycle Simon Wunderlich
2017-12-20 11:01 ` Simon Wunderlich [this message]
2017-12-20 11:01 ` [PATCH 03/19] batman-adv: Add SPDX license identifier above copyright header Simon Wunderlich
2017-12-20 11:01 ` [PATCH 04/19] batman-adv: Add SPDX license identifier to batman-adv.rst Simon Wunderlich
2017-12-20 11:01 ` [PATCH 09/19] batman-adv: Include net.h for net_ratelimited_function Simon Wunderlich
     [not found] ` <20171220110124.13117-1-sw-2YrNx6rUIHYiY0qSoAWiAoQuADTiUCJX@public.gmane.org>
2017-12-20 11:01   ` [PATCH 05/19] batman-adv: Add license header to Kconfig Simon Wunderlich
2017-12-20 11:01   ` [PATCH 06/19] batman-adv: Change batman_adv.h license to MIT Simon Wunderlich
2017-12-20 11:01   ` [PATCH 07/19] batman-adv: include gfp.h for GFP_* defines Simon Wunderlich
2017-12-20 11:01   ` [PATCH 08/19] batman-adv: include build_bug.h for BUILD_BUG_ON define Simon Wunderlich
2017-12-20 11:01   ` [PATCH 10/19] batman-adv: include kobject.h for kobject_* functions Simon Wunderlich
2017-12-20 11:01 ` [PATCH 11/19] batman-adv: Remove unused sched.h include Simon Wunderlich
2017-12-20 11:01 ` [PATCH 12/19] batman-adv: Add missing kernel-doc to packet.h Simon Wunderlich
2017-12-20 11:01 ` [PATCH 13/19] batman-adv: Use parentheses in function kernel-doc Simon Wunderlich
2017-12-20 11:01 ` [PATCH 14/19] batman-adv: Use inline kernel-doc for enum/struct Simon Wunderlich
2017-12-20 11:01 ` [PATCH 15/19] batman-adv: Fix kernel-doc references to struct members Simon Wunderlich
2017-12-20 11:01 ` [PATCH 16/19] batman-adv: Add kernel-doc to structs in headers Simon Wunderlich
2017-12-20 11:01 ` [PATCH 17/19] batman-adv: Add kernel-doc to enums " Simon Wunderlich
2017-12-20 11:01 ` [PATCH 18/19] batman-adv: Add kernel-doc to functions " Simon Wunderlich
2017-12-20 11:01 ` [PATCH 19/19] batman-adv: Add kernel-doc to externally visible functions Simon Wunderlich
2017-12-20 19:39 ` [PATCH 00/19] pull request for net-next: batman-adv 2017-12-20 David Miller
2017-12-21  5:58   ` [B.A.T.M.A.N.] " Sven Eckelmann

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=20171220110124.13117-3-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=dvlasenk@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sven@narfation.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;
as well as URLs for NNTP newsgroup(s).