From patchwork Mon Apr 16 20:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 898918 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="rmvqZx+S"; 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 40Q09F3Gcnz9s1B for ; Tue, 17 Apr 2018 06:19:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F1839F99; Mon, 16 Apr 2018 20:15:22 +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 1C4B2F73 for ; Mon, 16 Apr 2018 20:15:17 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 47A6C676 for ; Mon, 16 Apr 2018 20:15:16 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id q9so11064445pff.1 for ; Mon, 16 Apr 2018 13:15:16 -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=v8Hv32Xi5a9BmyhFRJ/VEtSy5UgrvSTtD6Ms6qUg4Kg=; b=rmvqZx+SicZyUXhT7XTpHo8+XWoEej9O5a7dbldUusnDUwyGolUjDttx5aVOoB7JR1 bQ8PGh391JfdL2oCqruph1yJoxOR+MxRIgmW4lsxVqxLmX4VAYhgqoToCWsf7fhfxffI Qs2IlwsM6nE2r6hlluhn162qoKwShmDSHRxJSshwx+g0vC+KasNOvolqZQGayqFZLtBb rUnCjCRl7qjpIs3Ern+JVbYMdQe1PD2b/PfbB6SRlHEMxoJtVtqXMOm2Y0Au9NfhOFBH 1DTqksECZJg88/E3b9c3WCtPkSXbEcUWdNqpsmhaVBC0WeusEn4S5uuNMKZ/Wi33lwP8 7/MA== 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=v8Hv32Xi5a9BmyhFRJ/VEtSy5UgrvSTtD6Ms6qUg4Kg=; b=uOOhpNAPHF+o06caAWQaQ63UyMkpxspV0AfgqTrWSO+AWzSsT3Pjq6+h1mjewihT0e aInq7GRcglwpWzl1nPTmGjdhMYk/4fDC2fvbTI0MOyyneB4ya4YWgssIMCHISyB8Aqh3 UDY3zvbG2p1CwJjr3ZIyxqmX6vGN7yW6pM155ND6sYEoFBZ4R8dqxNiiBRX5gSJz/wpj 9pEDjPBxFeMeqCuxp6wWLEbxqHuKrP5zi26oKdWi65uk5DesnroQs2b2uDdnRwkSltMx fM/B76rkIMbWEL9i71pJAJzPAp5accEmiWz+GiZGRzT51Re04hxlJ3lsfY0ysOuaIBFQ tS3w== X-Gm-Message-State: ALQs6tD+ordpDF71xENE7v2ZThc+c2IVktX1N8ToXexdLH3Ej2EdfzGF WhjkQUeuj51Rp6h7G7R1M7surg== X-Google-Smtp-Source: AIpwx49e7NDrYRC5Q6zBHG8oA+eDdP5N6ALvT8mPHARMKPpH+JcMmAAwSVwSemT88h6ECvUJYjAsLw== X-Received: by 10.98.56.144 with SMTP id f138mr6113286pfa.173.1523909715514; Mon, 16 Apr 2018 13:15:15 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.71]) by smtp.gmail.com with ESMTPSA id m7sm2306746pga.46.2018.04.16.13.15.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 13:15:15 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 16 Apr 2018 13:14:24 -0700 Message-Id: <1523909665-27961-10-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1523909665-27961-1-git-send-email-hzhou8@ebay.com> References: <1523909665-27961-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] [RFC v3 09/10] ovn-controller: Avoid forced recompute when not needed 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 Signed-off-by: Han Zhou --- ovn/controller/ovn-controller.c | 11 ++++++++--- ovn/lib/inc-proc-eng.c | 19 +++++++++++++++++++ ovn/lib/inc-proc-eng.h | 4 ++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index c9598f3..1b0bfda 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -1123,9 +1123,14 @@ main(int argc, char *argv[]) } if (old_engine_run_id == engine_run_id || !ctx.ovnsb_idl_txn || !ctx.ovs_idl_txn) { - VLOG_DBG("engine did not run, force recompute next time: " - "br_int %p, chassis %p", br_int, chassis); - engine_set_force_recompute(true); + if (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); + } else { + VLOG_DBG("engine did not run, and it was not needed either: " + "br_int %p, chassis %p", br_int, chassis); + } } else { engine_set_force_recompute(false); } diff --git a/ovn/lib/inc-proc-eng.c b/ovn/lib/inc-proc-eng.c index 54c7fd6..2e5e907 100644 --- a/ovn/lib/inc-proc-eng.c +++ b/ovn/lib/inc-proc-eng.c @@ -123,3 +123,22 @@ engine_run(struct engine_node *node, uint64_t run_id) } +bool +engine_need_run(struct engine_node *node) +{ + size_t i; + + if (!node->n_inputs) { + node->run(node); + VLOG_DBG("input node: %s, changed: %d", node->name, node->changed); + return node->changed; + } + + for (i = 0; i < node->n_inputs; i++) { + if (engine_need_run(node->inputs[i].node)) { + return true; + } + } + + return false; +} diff --git a/ovn/lib/inc-proc-eng.h b/ovn/lib/inc-proc-eng.h index 3e0ec16..c5deaa5 100644 --- a/ovn/lib/inc-proc-eng.h +++ b/ovn/lib/inc-proc-eng.h @@ -131,6 +131,10 @@ engine_run(struct engine_node *node, uint64_t run_id); void engine_cleanup(struct engine_node *node); +/* Check if engine needs to run, i.e. any change to be processed */ +bool +engine_need_run(struct engine_node *node); + /* Get the input node with for */ static inline struct engine_node * engine_get_input(const char *input_name, struct engine_node *node)