diff mbox series

[ovs-dev,v6,5/5] conntrack: Check for expiration before comparing the keys during the lookup

Message ID 165669926493.2104762.9912313397847070677.stgit@fed.void
State Superseded
Headers show
Series conntrack: Improve multithread scalability. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Paolo Valerio July 1, 2022, 6:14 p.m. UTC
From: Ilya Maximets <i.maximets@ovn.org>

This could save some costly key comparison miss, especially in the
case there are many expired connections waiting for the sweeper to
evict them.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
---
 lib/conntrack.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 9d7891d6a..4a0166ecb 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -583,14 +583,17 @@  conn_key_lookup(struct conntrack *ct, const struct conn_key *key,
     bool found = false;
 
     CMAP_FOR_EACH_WITH_HASH (conn, cm_node, hash, &ct->conns) {
-        if (!conn_key_cmp(&conn->key, key) && !conn_expired(conn, now)) {
+        if (conn_expired(conn, now)) {
+            continue;
+        }
+        if (!conn_key_cmp(&conn->key, key)) {
             found = true;
             if (reply) {
                 *reply = false;
             }
             break;
         }
-        if (!conn_key_cmp(&conn->rev_key, key) && !conn_expired(conn, now)) {
+        if (!conn_key_cmp(&conn->rev_key, key)) {
             found = true;
             if (reply) {
                 *reply = true;