Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386417 > unrolled thread

[PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes

Started byDenys Vlasenko <dvlasenk@redhat.com>
First post2016-04-25 15:30 +0200
Last post2016-04-25 16:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes Denys Vlasenko <dvlasenk@redhat.com> - 2016-04-25 15:30 +0200
    Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024  bytes Denys Vlasenko <dvlasenk@redhat.com> - 2016-04-25 15:50 +0200
      Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024  bytes Antonio Quartulli <a@unstable.cc> - 2016-04-25 16:30 +0200
    Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024  bytes Antonio Quartulli <a@unstable.cc> - 2016-04-25 16:10 +0200

#1386417 — [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes

FromDenys Vlasenko <dvlasenk@redhat.com>
Date2016-04-25 15:30 +0200
Subject[PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes
Message-ID<rrOKl-6zz-1@gated-at.bofh.it>
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 <dvlasenk@redhat.com>
CC: Marek Lindner <mareklindner@neomailbox.ch>
CC: Simon Wunderlich <sw@simonwunderlich.de>
CC: Antonio Quartulli <a@unstable.cc>
CC: Sven Eckelmann <sven@narfation.org>
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_ */
-- 
1.8.1.4

[toc] | [next] | [standalone]


#1386460 — Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes

FromDenys Vlasenko <dvlasenk@redhat.com>
Date2016-04-25 15:50 +0200
SubjectRe: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes
Message-ID<rrP3K-6Kr-35@gated-at.bofh.it>
In reply to#1386417
On 04/25/2016 03:39 PM, Antonio Quartulli wrote:
> On Mon, Apr 25, 2016 at 03:25:22PM +0200, Denys Vlasenko wrote:
>> 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
> 
> Hi Danys,
> 
> thanks for your patch. This function is used in a several performance critical
> code paths (i.e. packet forwarding).
> 
> Are we sure we are not losing in performance here?

Is this a common case?

	if (!hash)
		return NULL;

If yes, then we can inline this part only.

[toc] | [prev] | [next] | [standalone]


#1386516 — Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes

FromAntonio Quartulli <a@unstable.cc>
Date2016-04-25 16:30 +0200
SubjectRe: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes
Message-ID<rrPGq-7oh-35@gated-at.bofh.it>
In reply to#1386460

[Multipart message — attachments visible in raw view] — view raw

On Mon, Apr 25, 2016 at 03:45:20PM +0200, Denys Vlasenko wrote:
> On 04/25/2016 03:39 PM, Antonio Quartulli wrote:
> > On Mon, Apr 25, 2016 at 03:25:22PM +0200, Denys Vlasenko wrote:
> >> 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
> > 
> > Hi Danys,
> > 
> > thanks for your patch. This function is used in a several performance critical
> > code paths (i.e. packet forwarding).
> > 
> > Are we sure we are not losing in performance here?
> 
> Is this a common case?
> 
> 	if (!hash)
> 		return NULL;
> 
> If yes, then we can inline this part only.

Unfortunately not: this case is rather rare at runtime.
These hash tables are initialized when the batman virtual interface is created
and should be freed only upon interface shutdown.

(actually I believe this might be a good candidate for an unlikely())

Cheers,

-- 
Antonio Quartulli

[toc] | [prev] | [next] | [standalone]


#1386491 — Re: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes

FromAntonio Quartulli <a@unstable.cc>
Date2016-04-25 16:10 +0200
SubjectRe: [PATCH] batman-adv: Deinline batadv_orig_hash_find, save 9024 bytes
Message-ID<rrP3K-6Kr-37@gated-at.bofh.it>
In reply to#1386417

[Multipart message — attachments visible in raw view] — view raw

On Mon, Apr 25, 2016 at 03:25:22PM +0200, Denys Vlasenko wrote:
> 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

Hi Danys,

thanks for your patch. This function is used in a several performance critical
code paths (i.e. packet forwarding).

Are we sure we are not losing in performance here?

Cheers,

-- 
Antonio Quartulli

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web