summaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2015-03-31 17:07:03 -0700
committerAlex Wang <alexw@nicira.com>2015-04-06 14:26:56 -0700
commit131d04dcc4190d4202d605bd982047084e987fba (patch)
treed7e30ca1f3457ff26fdeb7866ecd5bdb7a7e47e0 /vswitchd
parent500ce35e8d2ef05295dd9e3b6147cd55dd79df55 (diff)
downloadopenvswitch-131d04dcc4190d4202d605bd982047084e987fba.tar.gz
bridge: Wait for previous stats update transation when it is incomplete.
When ovsdb happens to get blocked for few seconds, the 'stats_timer' will not be updated due to incompletion of previous transaction. When the current time passes the 'stats_timer', the call to poll_timer_wait_until(stats_timer) will keep waking up ovs-vswitchd, causing 100% cpu utilization. This commit fixes this issue by making ovs-vswitchd wait on the previous idl transaction when it is incomplete rather than the 'stats_timer'. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 5ea4d66e1..ea7d78838 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -203,6 +203,9 @@ static bool status_txn_try_again;
* timeout in 'STATUS_CHECK_AGAIN_MSEC' to check again. */
#define STATUS_CHECK_AGAIN_MSEC 100
+/* Statistics update to database. */
+static struct ovsdb_idl_txn *stats_txn;
+
/* Each time this timer expires, the bridge fetches interface and mirror
* statistics and pushes them into the database. */
static int stats_timer_interval;
@@ -2693,7 +2696,6 @@ refresh_controller_status(void)
static void
run_stats_update(void)
{
- static struct ovsdb_idl_txn *stats_txn;
const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(idl);
int stats_interval;
@@ -2748,6 +2750,18 @@ run_stats_update(void)
}
}
+static void
+stats_update_wait(void)
+{
+ /* If the 'stats_txn' is non-null (transaction incomplete), waits for the
+ * transaction to complete. Otherwise, waits for the 'stats_timer'. */
+ if (stats_txn) {
+ ovsdb_idl_txn_wait(stats_txn);
+ } else {
+ poll_timer_wait_until(stats_timer);
+ }
+}
+
/* Update bridge/port/interface status if necessary. */
static void
run_status_update(void)
@@ -3011,8 +3025,7 @@ bridge_wait(void)
HMAP_FOR_EACH (br, node, &all_bridges) {
ofproto_wait(br->ofproto);
}
-
- poll_timer_wait_until(stats_timer);
+ stats_update_wait();
status_update_wait();
}