vswitchd: Disable system stats collection on a concurrently running daemon.
authorGurucharan Shetty <gshetty@nicira.com>
Sun, 28 Apr 2013 02:58:12 +0000 (19:58 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Mon, 29 Apr 2013 23:51:33 +0000 (16:51 -0700)
There are very rare cases (ex: ovs-vswitchd.pid is inadvertantly deleted),
when multiple ovs-vswitchd daemons can end up running at the same time.
In a situation like that one of the daemons can wait on the poll()
with a 0 ms wait time as it would be expecting system stats to be collected.

But system stats are never run for the daemon that does not have the
lock on the database and hence it takes up 100% of the CPU if its state
machine for stats collection previously was S_WAITING.

With this patch, we disable the system stats collection for the daemon that
does not have the database lock. When it eventually gets the lock on the
database, system stats are automatically enabled if other_config:\
enable-statistics=true.

Bug #16669.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
vswitchd/bridge.c

index ef699df..724b4b9 100644 (file)
@@ -2218,6 +2218,10 @@ bridge_run(void)
             HMAP_FOR_EACH_SAFE (br, next_br, node, &all_bridges) {
                 bridge_destroy(br);
             }
+            /* Since we will not be running system_stats_run() in this process
+             * with the current situation of multiple ovs-vswitchd daemons,
+             * disable system stats collection. */
+            system_stats_enable(false);
             return;
         } else if (!ovsdb_idl_has_lock(idl)) {
             return;