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 <[email protected]> Signed-off-by: Alex Wang <[email protected]> --- PATCH -> V2: - simplify the code as Ben suggested. --- tests/ovs-vswitchd.at | 24 ++++++++++++++++++++++++ vswitchd/bridge.c | 9 ++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at index 4e7206a..3b7c516 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 2918f04..872820b 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; -- 1.7.9.5 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
