From patchwork Mon Apr 25 13:25:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denys Vlasenko X-Patchwork-Id: 15968 X-Patchwork-Delegate: mareklindner@neomailbox.ch 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 97DA680507; Mon, 25 Apr 2016 15:38:17 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=redhat.com Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=dvlasenk@redhat.com; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=redhat.com X-Greylist: delayed 570 seconds by postgrey-1.35 at open-mesh.org; Mon, 25 Apr 2016 15:35:02 CEST Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by open-mesh.org (Postfix) with ESMTPS id 9211E804C8 for ; Mon, 25 Apr 2016 15:35:02 +0200 (CEST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07BF085546; Mon, 25 Apr 2016 13:25:29 +0000 (UTC) Received: from localhost.localdomain (dhcp-1-191.brq.redhat.com [10.34.1.191]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3PDPQao015048; Mon, 25 Apr 2016 09:25:27 -0400 From: Denys Vlasenko To: Marek Lindner Date: Mon, 25 Apr 2016 15:25:22 +0200 Message-Id: <1461590722-2095-1-git-send-email-dvlasenk@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Mailman-Approved-At: Mon, 25 Apr 2016 15:38:16 +0200 Cc: Denys Vlasenko , b.a.t.m.a.n@lists.open-mesh.org, Antonio Quartulli , linux-kernel@vger.kernel.org Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 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" This function compiles to 473 bytes of machine code. 21 callsites. text data bss dec hex filename 95903266 20860288 35991552 152755106 91adba2 vmlinux_before 95894242 20860288 35991552 152746082 91ab862 vmlinux Signed-off-by: Denys Vlasenko CC: Marek Lindner CC: Simon Wunderlich CC: Antonio Quartulli CC: Sven Eckelmann CC: b.a.t.m.a.n@lists.open-mesh.org CC: linux-kernel@vger.kernel.org --- net/batman-adv/originator.c | 29 +++++++++++++++++++++++++++++ net/batman-adv/originator.h | 31 ++----------------------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index e4cbb07..bcf78f1 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -47,6 +47,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 4e8b67f..db7a87d 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h @@ -96,34 +96,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_ */