From: Alex Wang Date: Tue, 30 Sep 2014 20:46:22 +0000 (-0700) Subject: bridge: Fix high cpu utilization. X-Git-Tag: v2.3.1~23 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=367681a9213ab2d99177e222dad5ca69df1edf60 bridge: Fix high cpu utilization. When there are more than one ovs-vswitchd processes started, only one process is enabled. The disabled processes should just sleep. However, a bug in ovs makes the disabled processes keep waking up on global connectivity sequence number which is never sync'ed. Consequently, those processes use 100% cpu. This commit fixes the bug by always sync up the connectivity sequence number for disabled processes. Reported-by: Ben Pfaff Signed-off-by: Alex Wang Acked-by: Joe Stringer --- diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at index cbe0ee938..71a2b40ac 100644 --- a/tests/ovs-vswitchd.at +++ b/tests/ovs-vswitchd.at @@ -66,3 +66,40 @@ OVS_VSCTL_CHECK_RX_PKT([p1], [7]) OVS_VSWITCHD_STOP AT_CLEANUP + +dnl ---------------------------------------------------------------------- +AT_SETUP([ovs-vswitchd -- start additional ovs-vswitchd process]) +OVS_VSWITCHD_START + +# start another ovs-vswitchd process. +ovs-vswitchd --log-file=fakelog & +pid=`echo $!` + +# sleep for a while +sleep 5 + +# stop the process. +kill $pid + +# check the fakelog, should only see one ERR for reporting +# the existing ovs-vswitchd process and one WARN for killing +# the process. +AT_CHECK([grep ERR fakelog | wc -l], [0], [dnl +1 +]) + +AT_CHECK([grep WARN fakelog | wc -l], [0], [dnl +1 +]) + +AT_CHECK([grep ERR fakelog | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl +another ovs-vswitchd process is running, disabling this process () until it goes away +]) + +# check the fakelog, the ERR log should be the last line. +AT_CHECK([tail -n 2 fakelog | head -n 1 | sed -e 's/^.*ERR|//; s/pid [[0-9]]*//'], [0], [dnl +another ovs-vswitchd process is running, disabling this process () until it goes away +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 822b471d5..69d439637 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2311,6 +2311,9 @@ 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;