* [PATCH 0/5] More neigh simplifications.
@ 2011-07-17 19:29 David Miller
2011-07-18 13:16 ` [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf() Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2011-07-17 19:29 UTC (permalink / raw)
To: netdev
Add helpers for duplicate copies of code.
Eliminate superfluous ops methods that always get set to
the same exact function.
Get rid of hh->hh_output method.
I guess the indirection removal is a non-trivial improvement because
these changes knock a full 2 seconds off of my udpflood tests. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf()
2011-07-17 19:29 [PATCH 0/5] More neigh simplifications David Miller
@ 2011-07-18 13:16 ` Eric Dumazet
2011-07-18 17:42 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2011-07-18 13:16 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Le dimanche 17 juillet 2011 à 12:29 -0700, David Miller a écrit :
> I guess the indirection removal is a non-trivial improvement because
> these changes knock a full 2 seconds off of my udpflood tests. :-)
Excellent !
One other improvement is to get rid of ntohl(inet_make_mask(plen)) stuff
in check_leaf(), this saves 0.5 second on udpflood on my machine (27.25
second -> 26.75)
[PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf()
Compiler is not smart enough to avoid double BSWAP instructions in
ntohl(inet_make_mask(plen)).
Lets cache this value in struct leaf_info, (fill a hole on 64bit arches)
With route cache disabled, this saves ~2% of cpu in udpflood bench on
x86_64 machine.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/fib_trie.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 58c25ea..de9e297 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -110,9 +110,10 @@ struct leaf {
struct leaf_info {
struct hlist_node hlist;
- struct rcu_head rcu;
int plen;
+ u32 mask_plen; /* ntohl(inet_make_mask(plen)) */
struct list_head falh;
+ struct rcu_head rcu;
};
struct tnode {
@@ -451,6 +452,7 @@ static struct leaf_info *leaf_info_new(int plen)
struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL);
if (li) {
li->plen = plen;
+ li->mask_plen = ntohl(inet_make_mask(plen));
INIT_LIST_HEAD(&li->falh);
}
return li;
@@ -1359,10 +1361,8 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
hlist_for_each_entry_rcu(li, node, hhead, hlist) {
struct fib_alias *fa;
- int plen = li->plen;
- __be32 mask = inet_make_mask(plen);
- if (l->key != (key & ntohl(mask)))
+ if (l->key != (key & li->mask_plen))
continue;
list_for_each_entry_rcu(fa, &li->falh, fa_list) {
@@ -1394,7 +1394,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
#ifdef CONFIG_IP_FIB_TRIE_STATS
t->stats.semantic_match_passed++;
#endif
- res->prefixlen = plen;
+ res->prefixlen = li->plen;
res->nh_sel = nhsel;
res->type = fa->fa_type;
res->scope = fa->fa_info->fib_scope;
@@ -1402,7 +1402,7 @@ static int check_leaf(struct fib_table *tb, struct trie *t, struct leaf *l,
res->table = tb;
res->fa_head = &li->falh;
if (!(fib_flags & FIB_LOOKUP_NOREF))
- atomic_inc(&res->fi->fib_clntref);
+ atomic_inc(&fi->fib_clntref);
return 0;
}
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf()
2011-07-18 13:16 ` [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf() Eric Dumazet
@ 2011-07-18 17:42 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-07-18 17:42 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 18 Jul 2011 15:16:33 +0200
> [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf()
>
> Compiler is not smart enough to avoid double BSWAP instructions in
> ntohl(inet_make_mask(plen)).
>
> Lets cache this value in struct leaf_info, (fill a hole on 64bit arches)
>
> With route cache disabled, this saves ~2% of cpu in udpflood bench on
> x86_64 machine.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-18 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-17 19:29 [PATCH 0/5] More neigh simplifications David Miller
2011-07-18 13:16 ` [PATCH net-next-2.6] ipv4: save cpu cycles from check_leaf() Eric Dumazet
2011-07-18 17:42 ` David Miller
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).