From patchwork Fri Dec 6 13:38:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1205049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="OYeGAG70"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47TtwR6wczz9sSK for ; Sat, 7 Dec 2019 00:39:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 07E65884A8; Fri, 6 Dec 2019 13:39:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Oo3rTjvyQuVU; Fri, 6 Dec 2019 13:39:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 1BBA78849D; Fri, 6 Dec 2019 13:39:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 09CBDC18DD; Fri, 6 Dec 2019 13:39:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CF8E1C077D for ; Fri, 6 Dec 2019 13:38:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C2F098908C for ; Fri, 6 Dec 2019 13:38:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IdMXw82gmebG for ; Fri, 6 Dec 2019 13:38:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by hemlock.osuosl.org (Postfix) with ESMTPS id F161B8907F for ; Fri, 6 Dec 2019 13:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575639536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3DhGWaKkB3l2l0w/iifNes+3RMbtThMtOGNfsIGQKXM=; b=OYeGAG70UuNXYLj2W8hkSqg35iRs4HM7o7R+VLr3/QGPAc2EKDXqwcgBfTilx7EMV5oZEo Gh2uZa44r0JcA57ipCBArU1FKwZBdbZbRuEjIXqlrP5FkJWrVhxHnWyfzLJu8ga8EimZrb 5cVpUx0S1heL24iBQ3SIrKCDr7E3inU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-404-FYs8kje1MPWSJBQ9DxWe3g-1; Fri, 06 Dec 2019 08:38:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EA8CDB63; Fri, 6 Dec 2019 13:38:52 +0000 (UTC) Received: from dceara.remote.csb (ovpn-117-229.ams2.redhat.com [10.36.117.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9967A6B49A; Fri, 6 Dec 2019 13:38:50 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 6 Dec 2019 14:38:37 +0100 Message-Id: <1575639517-2266-1-git-send-email-dceara@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: FYs8kje1MPWSJBQ9DxWe3g-1 X-Mimecast-Spam-Score: 0 Cc: Han Zhou Subject: [ovs-dev] [PATCH ovn] ovn-controller: Run I-P engine even when no SB txn is available. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If the last ovn-controller main loop run started a transaction to the Southbound DB and the transaction is still in progress, ovn-controller will not call engine_run(). In case there were changes to the DB, engine_need_run() would return true which would trigger an immediate forced recompute in the next processing loop iteration. However, there are scenarios when updates can be processed incrementally even if no Southbound DB transaction is available. One example, often seen in the field, is when the MAC_Binding table is updated. Currently such an update received while a transaction is still committing would trigger a forced recompute. To minimize the number of forced recomputes, we now call engine_run(false), i.e., try to process updates incrementally without allowing recompute, also when ovnsb_idl_txn == NULL. This is safe because ovnsb_idl_txn is not used by change_handlers and run handlers are not allowed to execute when calling engine_run(false). To make sure that other users of ovnsb_idl_txn, like pinctrl_run(), get a chance to run as soon as the transaction is completed, if the engine has successfully run and ovnsb_idl_txn is NULL we trigger an immediate wake and a new iteration of the processing loop. CC: Han Zhou CC: Numan Siddique Signed-off-by: Dumitru Ceara --- controller/ovn-controller.c | 13 +++++++++++++ lib/inc-proc-eng.h | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 5874776..4a27d5f 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -2100,6 +2100,14 @@ main(int argc, char *argv[]) } else { engine_run(true); } + } else { + /* Even if there's no SB DB transaction available, + * try to run the engine so that we can handle any + * incremental changes that don't require a recompute. + * If a recompute is required, the engine will abort, + * triggerring a full run in the next iteration. + */ + engine_run(false); } stopwatch_stop(CONTROLLER_LOOP_STOPWATCH_NAME, time_msec()); @@ -2168,6 +2176,11 @@ main(int argc, char *argv[]) "br_int %p, chassis %p", br_int, chassis); engine_set_force_recompute(true); poll_immediate_wake(); + } else if (!ovnsb_idl_txn) { + VLOG_DBG("engine ran, no SB DB transaction available, " + "trigger an immediate loop run: " + "br_int %p, chassis %p", br_int, chassis); + poll_immediate_wake(); } else { engine_set_force_recompute(false); } diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index 5b92971..2f90b0a 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -189,7 +189,13 @@ 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); -const struct engine_context * engine_get_context(void); +/* Return the current engine_context. The values in the context can be NULL + * if the engine is run with allow_recompute == false in the current + * iteration. + * Therefore, it is the responsibility of the caller to check the context + * values when called from change_handlers. + */ +const struct engine_context *engine_get_context(void); void engine_set_context(const struct engine_context *);