[ovs-dev] [PATCH v2 09/11] conntrack: Do not rate limit ct-sweep
Gaetan Rivet
grive at u256.net
Wed Apr 21 22:11:23 UTC 2021
The current rate limit is set to allow other threads to update the
connections when applicable. This was valid when taking the 'ct_lock'
was needed with a global critical section.
Now that the size of the critical section for 'ct_lock' is reduced, it
is not necessary to rate limit calls to ct_sweep() anymore.
Signed-off-by: Gaetan Rivet <grive at u256.net>
Reviewed-by: Eli Britstein <elibr at nvidia.com>
---
lib/conntrack.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/lib/conntrack.c b/lib/conntrack.c
index ea2e5b63b..8a7538b7b 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -1675,20 +1675,12 @@ conntrack_clean(struct conntrack *ct, long long now)
* there is an actual connection that expires, or because a new connection
* might be created with the minimum timeout).
*
- * The logic below has two goals:
- *
- * - We want to reduce the number of wakeups and batch connection cleanup
- * when the load is not very high. CT_CLEAN_INTERVAL ensures that if we
- * are coping with the current cleanup tasks, then we wait at least
- * 5 seconds to do further cleanup.
- *
- * - We don't want to keep the map locked too long, as we might prevent
- * traffic from flowing. CT_CLEAN_MIN_INTERVAL ensures that if cleanup is
- * behind, there is at least some 200ms blocks of time when the map will be
- * left alone, so the datapath can operate unhindered.
+ * We want to reduce the number of wakeups and batch connection cleanup
+ * when the load is not very high. CT_CLEAN_INTERVAL ensures that if we
+ * are coping with the current cleanup tasks, then we wait at least
+ * 5 seconds to do further cleanup.
*/
#define CT_CLEAN_INTERVAL 5000 /* 5 seconds */
-#define CT_CLEAN_MIN_INTERVAL 200 /* 0.2 seconds */
static void *
clean_thread_main(void *f_)
@@ -1705,12 +1697,10 @@ clean_thread_main(void *f_)
long long now = time_msec();
next_wake = conntrack_clean(ct, now);
- if (next_wake < now) {
- poll_immediate_wake();
- } else if (next_wake < now + CT_CLEAN_MIN_INTERVAL) {
- poll_timer_wait_until(now + CT_CLEAN_MIN_INTERVAL);
+ if (next_wake > now) {
+ poll_timer_wait_until(MIN(next_wake, now + CT_CLEAN_INTERVAL));
} else {
- poll_timer_wait_until(MAX(next_wake, now + CT_CLEAN_INTERVAL));
+ poll_immediate_wake();
}
latch_wait(&ct->clean_thread_exit);
poll_block();
--
2.31.1
More information about the dev
mailing list