From patchwork Mon Feb 22 12:15:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1443085 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=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gO4Y3k6O; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dkh366R15z9sVX for ; Mon, 22 Feb 2021 23:15:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C2828839E4; Mon, 22 Feb 2021 12:15:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B1fC8VsFk7Vc; Mon, 22 Feb 2021 12:15:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTP id 7D747838FB; Mon, 22 Feb 2021 12:15:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4BE00C000B; Mon, 22 Feb 2021 12:15:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id E266FC0001 for ; Mon, 22 Feb 2021 12:15:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DD6ED83906 for ; Mon, 22 Feb 2021 12:15:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f518v5Ive8nt for ; Mon, 22 Feb 2021 12:15:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 60D2B838FB for ; Mon, 22 Feb 2021 12:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613996122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=knu4ezc0qGt30a5W7sa4EFxkJkqFRRlPDqwR38CzTlI=; b=gO4Y3k6OJ+dWQuSFDehclqCY/+97j/RRwhtva89PDnL5aPIxM/+Tne/+bDXVnlNB3fJK+P iN6jylR/yaOYAhiWulNvGXki/ROB2R9tN+azD2/dCCWoDx9hDPLGRE2zCmDeN1Z6hX7Pko 30J2i0aiOxSULx6otzS7O+ySTm6AuC4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499--L-5iGanO7qtlwGNMsaykg-1; Mon, 22 Feb 2021 07:15:20 -0500 X-MC-Unique: -L-5iGanO7qtlwGNMsaykg-1 Received: by mail-wm1-f71.google.com with SMTP id b62so4973866wmc.5 for ; Mon, 22 Feb 2021 04:15:20 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=knu4ezc0qGt30a5W7sa4EFxkJkqFRRlPDqwR38CzTlI=; b=OhYVTRbcE4dPIT9plaXG5dD6t0t5OausOfyeFSI2l2lMuDkHc0NcujiO9A47D4Qxec p/ZCFiyP1b98O52pR3hF4WIaonaGTMDGNTENZRGJ2MIj2kw4pkL1KcAxs5NfaLKUaibG MctTrz3JjtnKUl/hU2CmGxFWLfFwIHAE/IQRcxri2LG2sKIm9FZhxDmuT6MRtBAkNkFQ fbIoZuwnnqLV02mfKEqDzE7LaIvGkP97bzh2Fi0XldPlpT2kkOl+rR6z6m+zTmnoXeeB O+gXX1JRLZPQ72JC1Wd/0fKPSj93R33JAwFUdQ5EyLIaCVgsCUHqHiiB3X9NyVckwCDu o0kQ== X-Gm-Message-State: AOAM533bi9NK6CIUVdvrA5d7UeC2X1VhupfHzJNH0enRE/1t+9H+XXLL Kj61c00Cen4eqIgPJ5pU+vcSw+neIkG0S66XK9wPF8lLXH6VTTd5YbWZbd3bczHaLOS10hDAGtA 3KfPTPn0N+5DoCfTG6zVDXQHiLzK2xhXsn+c4EtxuezkNmvOIYajAj988SIVGh2MbPIQN1JphvL E= X-Received: by 2002:a1c:c3c5:: with SMTP id t188mr19714560wmf.167.1613996118842; Mon, 22 Feb 2021 04:15:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtuR11XvQjp0P6/4FJ+U6NmnY9nexdP74RXY/RjmzmFTGUAnATUjvGwPoetzWK7ReyCic13g== X-Received: by 2002:a1c:c3c5:: with SMTP id t188mr19714524wmf.167.1613996118508; Mon, 22 Feb 2021 04:15:18 -0800 (PST) Received: from lore-desk.redhat.com ([151.66.54.126]) by smtp.gmail.com with ESMTPSA id u12sm1855895wmq.38.2021.02.22.04.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 04:15:18 -0800 (PST) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Mon, 22 Feb 2021 13:15:14 +0100 Message-Id: <1a4940b05c36d4d5783e59dfc4f3b9b4fa8de0cd.1613996071.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH v4 ovn] controller: introduce stats counters for ovn-controller incremental processing 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Introduce inc-engine/stats ovs-applctl command in order to dump ovn-controller incremental processing engine statistics. So far for each node a counter for run, abort and engine_handler have been added. Counters are incremented when the node move to "updated" state. In order to dump I-P stats we can can use the following commands: $ovs-appctl -t ovn-controller inc-engine/stats SB_address_set run 1 abort 0 change-handler 0 addr_sets run 2 abort 1 change-handler 0 SB_port_group run 0 abort 0 change-handler 0 port_groups run 2 abort 0 change-handler 0 ofctrl_is_connected run 1 abort 0 change-handler 0 OVS_open_vswitch run 0 abort 0 change-handler 0 OVS_bridge run 0 abort 0 change-handler 0 OVS_qos run 0 abort 0 change-handler 0 SB_chassis run 1 abort 0 change-handler 0 .... flow_output run 2 abort 0 change-handler 34 Morover introduce the inc-engine/stats-clear command to reset engine statistics $ovs-appctl -t ovn-controller inc-engine/stats-clear Signed-off-by: Lorenzo Bianconi --- Changes since v3: - drop engine_set_note_update_from_run/engine_set_note_update_from_handler macros and move stats code in lib/inc-proc-eng.c - fix commit log Changes since v2: - introduce inc-engine/stats and inc-engine/stats-clear commands and drop COVERAGE_* dependency Changes since v1: - drop handler counters and add global abort counter - improve documentation and naming scheme - introduce engine_set_node_updated utility macro --- controller/ovn-controller.c | 4 ++++ lib/inc-proc-eng.c | 35 +++++++++++++++++++++++++++++++++++ lib/inc-proc-eng.h | 18 ++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 5dd643f52..52e7b1932 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -2710,6 +2710,10 @@ main(int argc, char *argv[]) unixctl_command_register("recompute", "", 0, 0, engine_recompute_cmd, NULL); + unixctl_command_register("inc-engine/stats", "", 0, 0, engine_dump_stats, + NULL); + unixctl_command_register("inc-engine/stats-clear", "", 0, 0, + engine_clear_stats, NULL); unixctl_command_register("lflow-cache/flush", "", 0, 0, lflow_cache_flush_cmd, &flow_output_data->pd); diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c index 916dbbe39..facd59e5b 100644 --- a/lib/inc-proc-eng.c +++ b/lib/inc-proc-eng.c @@ -283,11 +283,13 @@ engine_recompute(struct engine_node *node, bool forced, bool allowed) if (!allowed) { VLOG_DBG("node: %s, recompute aborted", node->name); engine_set_node_state(node, EN_ABORTED); + node->stats.abort++; return; } /* Run the node handler which might change state. */ node->run(node, node->data); + node->stats.run++; } /* Return true if the node could be computed, false otherwise. */ @@ -310,6 +312,7 @@ engine_compute(struct engine_node *node, bool recompute_allowed) engine_recompute(node, false, recompute_allowed); return (node->state != EN_ABORTED); } + node->stats.change_handler++; } } return true; @@ -401,3 +404,35 @@ engine_need_run(void) } return false; } + +void +engine_clear_stats(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED) +{ + for (size_t i = 0; i < engine_n_nodes; i++) { + struct engine_node *node = engine_nodes[i]; + + memset(&node->stats, 0, sizeof(node->stats)); + } + unixctl_command_reply(conn, NULL); +} + +void +engine_dump_stats(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED) +{ + struct ds dump = DS_EMPTY_INITIALIZER; + + for (size_t i = 0; i < engine_n_nodes; i++) { + struct engine_node *node = engine_nodes[i]; + + ds_put_format(&dump, "%s\n", node->name); + ds_put_format(&dump, "\trun\t%lu", node->stats.run); + ds_put_format(&dump, "\tabort\t%lu", node->stats.abort); + ds_put_format(&dump, "\tchange-handler\t%lu\n", + node->stats.change_handler); + } + unixctl_command_reply(conn, ds_cstr(&dump)); + + ds_destroy(&dump); +} diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index 857234677..bc8744a0d 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -60,6 +60,8 @@ * against all its inputs. */ +#include "unixctl.h" + #define ENGINE_MAX_INPUT 256 #define ENGINE_MAX_OVSDB_INDEX 256 @@ -107,6 +109,12 @@ enum engine_node_state { EN_STATE_MAX, }; +struct engine_stats { + unsigned long run; + unsigned long abort; + unsigned long change_handler; +}; + struct engine_node { /* A unique name for each node. */ char *name; @@ -154,6 +162,9 @@ struct engine_node { /* Method to clear up tracked data maintained by the engine node in the * engine 'data'. It may be NULL. */ void (*clear_tracked_data)(void *tracked_data); + + /* Engine stats */ + struct engine_stats stats; }; /* Initialize the data for the engine nodes. It calls each node's @@ -312,6 +323,7 @@ en_##DB_NAME##_##TBL_NAME##_run(struct engine_node *node, \ EN_OVSDB_GET(node); \ if (DB_NAME##rec_##TBL_NAME##_table_track_get_first(table)) { \ engine_set_node_state(node, EN_UPDATED); \ + node->stats.run++; \ return; \ } \ engine_set_node_state(node, EN_UNCHANGED); \ @@ -352,4 +364,10 @@ static void en_##DB_NAME##_##TBL_NAME##_cleanup(void *data OVS_UNUSED) \ #define ENGINE_NODE_OVS(TBL_NAME, TBL_NAME_STR) \ ENGINE_NODE_OVSDB(ovs, "OVS", TBL_NAME, TBL_NAME_STR); + +void engine_dump_stats(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED); +void engine_clear_stats(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED); + #endif /* lib/inc-proc-eng.h */