From patchwork Sun Nov 19 16:59:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17139 X-Patchwork-Delegate: sven@narfation.org 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 13123812BD; Sun, 19 Nov 2017 17:59:26 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="wB7ape1w"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id D0A54805EB for ; Sun, 19 Nov 2017 17:59:23 +0100 (CET) Received: from sven-desktop.home.narfation.org (p200300C593EBC3FD792CD3ECD963554B.dip0.t-ipconnect.de [IPv6:2003:c5:93eb:c3fd:792c:d3ec:d963:554b]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id A3BA51100E8; Sun, 19 Nov 2017 17:59:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1511110761; bh=zymz7zGCPhA1mHmxDeAWAbSr2OdDKiNRmWk9h0rin7A=; h=From:To:Cc:Subject:Date:From; b=wB7ape1w/wnqnbInL6Bs7ToPiTHNLTaOnM2+uv/N1e14kIavTE9T6/S24B3szq/OE Xlr+AxGg9VvxCwPqpm1yqwthQWI7D7OIB/3jTWvoNgYE4PSxm+/5H7WIT3L5FjtU88 eyGZwOrKXsoneTKeJ2Nz0GZK1OcZ4+bYcLviAzrc= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 19 Nov 2017 17:59:13 +0100 Message-Id: <20171119165913.23313-1-sven@narfation.org> X-Mailer: git-send-email 2.11.0 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 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 Cc: Denys Vlasenko 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 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 [sven@narfation.org: Fix includes, correct sizes+counts in commit message] Signed-off-by: Sven Eckelmann --- 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 #include #include +#include #include #include #include #include +#include #include #include #include @@ -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 #include #include -#include -#include -#include -#include #include -#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_ */