small optimization in __ip_conntrack_find()
Subsystems (2)
PATCH 1/1 small optimization in __ip_conntrack_find()
Hi,
Attached is a small optimization for __ip_conntrack_find(). The way I read the use of the LIST_FIND macro it seems that we are calling hash_conntrack() for each iteration with the same inparameters.
My change calls it once before looping.
Signature · 4 lines
/Martin Never argue with an idiot. They drag you down to their level, then beat you with experience.
net/ipv4/netfilter/ip_conntrack_core.c renamed from net/ipv4/netfilter/ip_conntrack_core.c.orig +2 -1
@@ -292,9 +292,10 @@ const struct ip_conntrack *ignored_conntrack) {struct ip_conntrack_tuple_hash *h; +size_t hash =hash_conntrack (tuple);MUST_BE_READ_LOCKED (&ip_conntrack_lock); - h =LIST_FIND (&ip_conntrack_hash[hash_conntrack (tuple)], + h =LIST_FIND (&ip_conntrack_hash[hash], conntrack_tuple_cmp, struct ip_conntrack_tuple_hash *, tuple, ignored_conntrack);
Quoted 5 lines · Martin Josefsson
Hi,
Attached is a small optimization for
__ip_conntrack_find(). The way I read the use of theLIST_FINDmacro it seems that we are callinghash_conntrack()for each iteration with the same inparameters.
Thanks. My assumption was that this is actually done by the optimization code of gcc. But from looking at the disassembled compiler output, there is actually quite a difference between the old and the new code.
Quoted 1 line
My change calls it once before looping.
i'll put this into pending.
Quoted 1 line
/Martin
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+ V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)