From patchwork Tue Jul 30 01:33:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1138736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oabe4I45"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45yK382MS0z9sBZ for ; Tue, 30 Jul 2019 11:38:59 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5353C25EF; Tue, 30 Jul 2019 01:38:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4E52125CF for ; Tue, 30 Jul 2019 01:34:01 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EF7A6A8 for ; Tue, 30 Jul 2019 01:34:00 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id w10so29156093pgj.7 for ; Mon, 29 Jul 2019 18:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jyW4oihxSUYWnmMuac2+2mMCR2iYP1tUrOxjY1QcB4I=; b=oabe4I45F/3zhmXALdVt7+qYw9lkxU0r5+zcBNo+LnQOMIvsLA4C/RC+UDz9hBBrBg gysw7XMpZs7PnSxb2b3AWp+aI7udRMZ5nwXucHYDfJuJeyrwlEuEsDFJj0/iFBOGsqUy TjNRp55R9kzNEWtnSr71dshY3cxQHfG4YHZeyK8a2gM+Utj9RV1mb+YvptWqbmSU8JSP st9I8gFH4kmx2K1Bab0TehtW8OLiRZM42MTik6TNmJwlVBZdvUPP5K9awyXtwVR6F+aA rB6LzZOFo/hgE2DAg8Sv/Bb9h5v7zQQ9nCOen5SAMDRHOUuxBMoxEdapWUzYq98Re1N5 u7mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jyW4oihxSUYWnmMuac2+2mMCR2iYP1tUrOxjY1QcB4I=; b=FhQ4OO4hI1XpfGuPB9s/VT5SyZ8XhxjnbxNsIu2secTvxzK8JTg/fmu9ENlZF67pyB 5TdiJeF5MLXG9AaLFYsYngNUNPjHv76wc78+MnZt/mGBkVwopUhzZtmNf1PB1cLG1am7 slBwt+AhkBFr/b6cdVr4t2YVxlEJkh/LhqFryc8iDUMf7PK9YFU2SSTiFraxFM0Hr+Js bZbgYlo1R3G+/JwPuC/1LPZXWrkG6h0VGB5HLcFp/EHKmU7bLsFh50OYXzkyTmIeFPJy 8gVLCXgbJv/rN9cR7dfR/rXEgNl98ZUfCeeuTAq3nNQXauFPlVSv0FwKZTE21BR/X4KR FLyw== X-Gm-Message-State: APjAAAVO7bAlpmaD13naO84MiUsc8k9phCW/Ig1OtBspz88SFVZnaeLu 8lVdLo1nCkHd2cnlQAxxGbx+u3sIOKE= X-Google-Smtp-Source: APXvYqzlAGbYoafeN4QaMIjtUb0in3TqIEIavEtHr2cfuUzxsy9wNVye7LP0s5suwCJhZ5pT1YSxLA== X-Received: by 2002:a63:2f44:: with SMTP id v65mr104647425pgv.185.1564450440172; Mon, 29 Jul 2019 18:34:00 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.77]) by smtp.gmail.com with ESMTPSA id t7sm56830431pfh.101.2019.07.29.18.33.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 18:33:59 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 29 Jul 2019 18:33:53 -0700 Message-Id: <1564450434-104928-1-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH ovn 1/2] ovn-controller: Fix path for lib/inc-proc-eng.h after OVN split. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou Signed-off-by: Han Zhou --- controller/ovn-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 12c919a..d3b28b9 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -63,7 +63,7 @@ #include "timeval.h" #include "timer.h" #include "stopwatch.h" -#include "ovn/lib/inc-proc-eng.h" +#include "lib/inc-proc-eng.h" VLOG_DEFINE_THIS_MODULE(main); From patchwork Tue Jul 30 01:33:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1138737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OCQlS4ow"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45yK3j3dKjz9sBZ for ; Tue, 30 Jul 2019 11:39:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8BBFA260A; Tue, 30 Jul 2019 01:38:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A53A825CF for ; Tue, 30 Jul 2019 01:34:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E5583A8 for ; Tue, 30 Jul 2019 01:34:01 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id o13so29131884pgp.12 for ; Mon, 29 Jul 2019 18:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LHUInGZgUVHdYywz/FoycC+bBV2zibuLyORjwMZNU/8=; b=OCQlS4owEmvdYS+jnUR1n+fVnDihGqdHiX6VBfsOvWIDY7FNWYpYjv0xixABqadZzr jGSr3zLX85HMGTlUrBmImsE/YA+w92Kjmn5J1AQJy7vLy7lcCNbzPVGSdjRSfIq3jS05 6/WT3VLT6kEyOz8DsoC1EhsiCak1S+Le2lxjR81x5P6dkJ5DuZsjAVvpuV3ZdIhcFJwJ cCQCu5JGEodXcqx1GhESXSgb0lS2s0ztSH31JDpHZCATLl2T8fele5bpHy/7cb1hYmGZ EI6ZHiIO3GWvUy+BG2l/GH3NRuZthHV71GV7mwpdlxLYmPxSZqTcu9JxcG520UJKStgd 2wIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LHUInGZgUVHdYywz/FoycC+bBV2zibuLyORjwMZNU/8=; b=lU8MW/rbz0OVIxIb0EgZzR3z8XzbJEo46uzmZlnDX/UzZhal1nEEAwdLJNLUCTzLik ABrP00NzGmw2qcCg0e+9sU3k3hhRZATwF3bkIg3F3aKY46aoWc/ushspSFmsH9dGzyLT OxIqEDeNyh37hmaQpthlQjOryQj2njICYXQsRbAPmJzTgKN+ZlaiJz7m/Smcjqqc99iB IUnpkp2Gu68UMst+M9TwuQ4SO1wET3QcUB3VW27IHKGAYHGCewvMFBfBXZHSjG/RrO1q hbLdliJi5F+7YQ4A0wIPMmqDVGe548Acw0Lltd3gjOKCg477Dg/pQg9GF9LRZWM3fE58 +EqA== X-Gm-Message-State: APjAAAWBJknz/vAuxLZfOie2IsLXtBwzjHwN3waO8pm9EvdJ6as82CU/ lvC8NZ/uYgUIGuuE06DnQgq09Vly/RQ= X-Google-Smtp-Source: APXvYqwGkswab3Yla7BNVCj+SgUBxbjk0DtmJkNiHMm+xoCNAbSkUSvT7AE3+8b+NVr/nIk5jA4RUQ== X-Received: by 2002:a63:1908:: with SMTP id z8mr104085372pgl.433.1564450441218; Mon, 29 Jul 2019 18:34:01 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.77]) by smtp.gmail.com with ESMTPSA id t7sm56830431pfh.101.2019.07.29.18.34.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 18:34:00 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 29 Jul 2019 18:33:54 -0700 Message-Id: <1564450434-104928-2-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1564450434-104928-1-git-send-email-hzhou8@ebay.com> References: <1564450434-104928-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH ovn 2/2] ovn-controller: Fix flow installation latency caused by recompute. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou When there are in-flight flow-installations pending to ovs-vswitchd, current incremental processing logic prioritizes new change handling. However, in scenarios where frequent recomputes are triggered, the later recompute would block the flow-installation for previously computed flows because recompute usually takes long time, especially when there are large number of flows. This results in worse latency than the version without incremental processing in specific scale test scenarios. While we can simply fix the problem by prioritizing flow installation rather than new change handling, it can cause the incremental processing to degrade to always recompute in certain scenarios when there are some changes triggering recomputes, followed by a lot of continously coming changes that can be handled incrementally. Because OVSDB change tracker cannot preserve changes across iterations, once the recompute is triggered and resulted in a lot of pending messages to ovs-vswitchd, and if we choose to skip the engine_run() in the next iteration when a incrementally processible change comes, we miss the opportunity to handle that tracked change and will have to trigger recompute again in the next next iteration, and so on, if such changes come continously. This patch solves the problem by introducing engine_set_abort_recompute(), so that we can prioritize new change handling if the change can be incrementally processed, but if the change triggers recompute, we abort there without spending CPU on the recompute to avoid blocking the previous computed flow installation. Reported-by: Daniel Alvarez Sanchez Reported-by: Numan Siddique Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048822.html Tested-by: Numan Siddique Acked-by: Numan Siddique Acked-by: Mark Michelson Signed-off-by: Han Zhou --- controller/ofctrl.c | 2 +- controller/ofctrl.h | 1 + controller/ovn-controller.c | 30 +++++++++++++++++++++++++++--- lib/inc-proc-eng.c | 26 ++++++++++++++++++++++---- lib/inc-proc-eng.h | 9 +++++++-- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/controller/ofctrl.c b/controller/ofctrl.c index 4d24a8b..8928205 100644 --- a/controller/ofctrl.c +++ b/controller/ofctrl.c @@ -985,7 +985,7 @@ add_meter(struct ovn_extend_table_info *m_desired, * in the correct state and not backlogged with existing flow_mods. (Our * criteria for being backlogged appear very conservative, but the socket * between ovn-controller and OVS provides some buffering.) */ -static bool +bool ofctrl_can_put(void) { if (state != S_UPDATE_FLOWS diff --git a/controller/ofctrl.h b/controller/ofctrl.h index 114c9ef..1e9ac16 100644 --- a/controller/ofctrl.h +++ b/controller/ofctrl.h @@ -51,6 +51,7 @@ void ofctrl_put(struct ovn_desired_flow_table *, const struct sbrec_meter_table *, int64_t nb_cfg, bool flow_changed); +bool ofctrl_can_put(void); void ofctrl_wait(void); void ofctrl_destroy(void); int64_t ofctrl_get_cur_cfg(void); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index d3b28b9..ad33d17 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1896,6 +1896,7 @@ main(int argc, char *argv[]) uint64_t engine_run_id = 0; uint64_t old_engine_run_id = 0; + bool engine_aborted = false; unsigned int ovs_cond_seqno = UINT_MAX; unsigned int ovnsb_cond_seqno = UINT_MAX; @@ -1982,7 +1983,30 @@ main(int argc, char *argv[]) stopwatch_start(CONTROLLER_LOOP_STOPWATCH_NAME, time_msec()); if (ovnsb_idl_txn) { - engine_run(&en_flow_output, ++engine_run_id); + if (!ofctrl_can_put()) { + /* When there are in-flight messages pending to + * ovs-vswitchd, we should hold on recomputing so + * that the previous flow installations won't be + * delayed. However, we still want to try if + * recompute is not needed and we can quickly + * incrementally process the new changes, to avoid + * unnecessarily forced recomputes later on. This + * is because the OVSDB change tracker cannot + * preserve tracked changes across iterations. If + * change tracking is improved, we can simply skip + * this round of engine_run and continue processing + * acculated changes incrementally later when + * ofctrl_can_put() returns true. */ + if (!engine_aborted) { + engine_set_abort_recompute(true); + engine_aborted = engine_run(&en_flow_output, + ++engine_run_id); + } + } else { + engine_set_abort_recompute(false); + engine_aborted = false; + engine_run(&en_flow_output, ++engine_run_id); + } } stopwatch_stop(CONTROLLER_LOOP_STOPWATCH_NAME, time_msec()); @@ -2024,8 +2048,8 @@ main(int argc, char *argv[]) } } - if (old_engine_run_id == engine_run_id) { - if (engine_need_run(&en_flow_output)) { + if (old_engine_run_id == engine_run_id || engine_aborted) { + if (engine_aborted || engine_need_run(&en_flow_output)) { VLOG_DBG("engine did not run, force recompute next time: " "br_int %p, chassis %p", br_int, chassis); engine_set_force_recompute(true); diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c index 1ddea1a..1064a08 100644 --- a/lib/inc-proc-eng.c +++ b/lib/inc-proc-eng.c @@ -31,6 +31,7 @@ VLOG_DEFINE_THIS_MODULE(inc_proc_eng); static bool engine_force_recompute = false; +static bool engine_abort_recompute = false; static const struct engine_context *engine_context; void @@ -39,6 +40,12 @@ engine_set_force_recompute(bool val) engine_force_recompute = val; } +void +engine_set_abort_recompute(bool val) +{ + engine_abort_recompute = val; +} + const struct engine_context * engine_get_context(void) { @@ -121,11 +128,11 @@ engine_ovsdb_node_add_index(struct engine_node *node, const char *name, ed->n_indexes ++; } -void +bool engine_run(struct engine_node *node, uint64_t run_id) { if (node->run_id == run_id) { - return; + return true; } node->run_id = run_id; @@ -133,11 +140,13 @@ engine_run(struct engine_node *node, uint64_t run_id) if (!node->n_inputs) { node->run(node); VLOG_DBG("node: %s, changed: %d", node->name, node->changed); - return; + return true; } for (size_t i = 0; i < node->n_inputs; i++) { - engine_run(node->inputs[i].node, run_id); + if (!engine_run(node->inputs[i].node, run_id)) { + return false; + } } bool need_compute = false; @@ -160,6 +169,10 @@ engine_run(struct engine_node *node, uint64_t run_id) if (need_recompute) { VLOG_DBG("node: %s, recompute (%s)", node->name, engine_force_recompute ? "forced" : "triggered"); + if (engine_abort_recompute) { + VLOG_DBG("node: %s, recompute aborted", node->name); + return false; + } node->run(node); } else if (need_compute) { for (size_t i = 0; i < node->n_inputs; i++) { @@ -170,6 +183,10 @@ engine_run(struct engine_node *node, uint64_t run_id) VLOG_DBG("node: %s, can't handle change for input %s, " "fall back to recompute", node->name, node->inputs[i].node->name); + if (engine_abort_recompute) { + VLOG_DBG("node: %s, recompute aborted", node->name); + return false; + } node->run(node); break; } @@ -178,6 +195,7 @@ engine_run(struct engine_node *node, uint64_t run_id) } VLOG_DBG("node: %s, changed: %d", node->name, node->changed); + return true; } bool diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index 6f0d08d..3a69dc2 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -121,8 +121,9 @@ struct engine_node { void engine_init(struct engine_node *); /* Execute the processing recursively, which should be called in the main - * loop. */ -void engine_run(struct engine_node *, uint64_t run_id); + * loop. Returns true if the execution is compelte, false if it is aborted, + * which could happen when engine_abort_recompute is set. */ +bool engine_run(struct engine_node *, uint64_t run_id); /* Clean up the data for the engine nodes recursively. It calls each node's * cleanup() method if not NULL. It should be called before the program @@ -150,6 +151,10 @@ void engine_add_input(struct engine_node *node, struct engine_node *input, * iteration, and the change can't be tracked across iterations */ void engine_set_force_recompute(bool val); +/* Set the flag to cause engine execution to be aborted when there + * is any recompute to be triggered in any node. */ +void engine_set_abort_recompute(bool val); + const struct engine_context * engine_get_context(void); void engine_set_context(const struct engine_context *);