summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2014-10-09 08:23:37 +0000
committerAlex Wang <alexw@nicira.com>2014-10-09 09:27:53 -0700
commit5aca3322a1597575892d52188612f3b89860020b (patch)
tree28e8455d60f85687d963d01d163947630797de41
parentba119c1371f2579dc412855a46b533e442210f4d (diff)
downloadopenvswitch-5aca3322a1597575892d52188612f3b89860020b.tar.gz
ovs-vswitchd: Fix high cpu utilization when acquire idl lock fails.
When ovs-vswitchd fails to acquire the ovsdb idl lock (either due to contention or due to invalid database path), ovs-vswitchd will spin on the global connectivity sequence number and consume 100% cpu. This is in that the local copy is different to the global sequence number and never updated when ovsdb idl is not locked. To fix this issue, this commit makes ovs-vswitchd not checking the global connectivity sequence number in that situation. Reported-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--tests/ovs-vswitchd.at24
-rw-r--r--vswitchd/bridge.c9
2 files changed, 30 insertions, 3 deletions
diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at
index 4e7206af6..3b7c51653 100644
--- a/tests/ovs-vswitchd.at
+++ b/tests/ovs-vswitchd.at
@@ -129,3 +129,27 @@ AT_CHECK([sed -n "
# cleanup.
kill `cat ovsdb-server.pid`
AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+AT_SETUP([ovs-vswitchd -- invalid database path])
+
+# start an ovs-vswitchd process with invalid db path.
+ovs-vswitchd unix:invalid.db.sock --log-file=fakelog --enable-dummy --unixctl="`pwd`"/unixctl &
+
+# sleep for a while.
+sleep 10
+
+# stop the process.
+ovs-appctl -t `pwd`/unixctl exit
+
+# should not see this log (which indicates high cpu utilization).
+AT_CHECK([grep "wakeup due to" fakelog], [ignore])
+
+# check the fakelog, should not see any WARN/ERR/EMER log.
+AT_CHECK([sed -n "
+/|WARN|/p
+/|ERR|/p
+/|EMER|/p" fakelog
+])
+
+AT_CLEANUP
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 2918f049f..872820bf9 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2734,6 +2734,12 @@ run_status_update(void)
static void
status_update_wait(void)
{
+ /* This prevents the process from constantly waking up on
+ * connectivity seq, when there is no connection to ovsdb. */
+ if (!ovsdb_idl_has_lock(idl)) {
+ return;
+ }
+
/* If the 'status_txn' is non-null (transaction incomplete), waits for the
* transaction to complete. If the status update to database needs to be
* run again (transaction fails), registers a timeout in
@@ -2796,9 +2802,6 @@ bridge_run(void)
* with the current situation of multiple ovs-vswitchd daemons,
* disable system stats collection. */
system_stats_enable(false);
- /* This prevents the process from constantly waking up on
- * connectivity seq. */
- connectivity_seqno = seq_read(connectivity_seq_get());
return;
} else if (!ovsdb_idl_has_lock(idl)) {
return;