From patchwork Thu Jul 21 23:28:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16564 Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id EEE6582DCC; Fri, 22 Jul 2016 01:28:18 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=LY2cepZV; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 8D0BE82DCB for ; Fri, 22 Jul 2016 01:28:14 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C0FCF90000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c0:fcf9::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id E27981100F1; Fri, 22 Jul 2016 01:28:13 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1469143694; bh=cJZ9UpmiKBXSDQFBmAdejImfbz7uLjRsef9ME07niKo=; h=From:To:Cc:Subject:Date:From; b=LY2cepZVt0M5UuTg+33V8PoktNEb6fTIyY4i5s0iq+K0eez83PifTvPYduA8GNEf8 EoZau8DLjvQvLQ8+u8iBUMSxOgtSGuu/Lx3qzwCYe3kcqDHmOUMRY4LxrEWZj1QnAy gcOI8LWw5WndVSr/4D9o/chzOCpLx3t2YlXos5TM= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 22 Jul 2016 01:28:09 +0200 Message-Id: <1469143689-15357-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 Cc: Denys Vlasenko Subject: [B.A.T.M.A.N.] [RFC v2] batman-adv: Deinline batadv_orig_hash_find, save 6698 bytes X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Denys Vlasenko This function compiles to 283 bytes of machine code for 4.6.0-1-amd64 on Debian with the default configuration. 26 callsites (24 used in default config). text data bss dec hex filename 152667 10445 4160 167272 28d68 batman-adv.ko.pre 145969 10445 4160 160574 2733e batman-adv.ko.post Signed-off-by: Denys Vlasenko [sven@narfation.org: Fix includes, correct sizes+counts in commit message] Signed-off-by: Sven Eckelmann --- 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 0b7d57a..f81aba0 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -30,10 +30,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -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 ebc5618..68e9708 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h @@ -23,14 +23,8 @@ #include #include #include -#include -#include -#include -#include #include -#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_ */