From patchwork Wed Nov 6 09:48:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11229839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 119BC1599 for ; Wed, 6 Nov 2019 09:49:31 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3E5A2178F for ; Wed, 6 Nov 2019 09:49:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3E5A2178F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 3D2C66069807; Wed, 6 Nov 2019 09:49:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 3D2C66069807 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 337455AA79C8C; Wed, 6 Nov 2019 09:49:30 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 75EB65AA79C9D; Wed, 6 Nov 2019 09:49:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=disabled version=3.4.0 Received: from smtp-mm-ib01.fedoraproject.org (smtp-mm-ib01.vpn.fedoraproject.org [192.168.1.83]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id E11DE5AA79C98 for ; Wed, 6 Nov 2019 09:49:18 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-ib01.fedoraproject.org (Postfix) with ESMTPS id 7E27B605D243 for ; Wed, 6 Nov 2019 09:49:18 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id p26so18440774pfq.8 for ; Wed, 06 Nov 2019 01:49:18 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jGxhGDTdiZN7MjIvyIXv15e51adrPJA+sJsZMitd6lg=; b=KVNbqnCY2S3G28nNEBxnJuZX75aDtwlPRkh5au2Nd6n8ZgH8NT7GOE1rEUjtOHUSnS L5ZYwLzI/2F1JOFFz/we/LYlwxpAkLZhO6WUFhW/dyhrnoV8MhxpkoC4fNKQbB5fzjU5 fOj45Nm18MOZPUfl5QHJq6Z6v1u0VZyPRY+LDz6D8UWo60OMeaNTXRCxwYC/Q+su56HV 2JxYYwAF3k3VS/dnfsjDH8cQDgTd3LCmUBgDr1fJ2brniiJyapJiZJDxk1Quk5EzxzT2 2dNEH7kSQwDePwBUmUYfZyxgRITOMLiSka7MHxSO24voJ/T+GMrlqgse9l1D1o6fJLAP rvaQ== X-Gm-Message-State: APjAAAWFu3NJ0EHg/sdhVwTDaiypBdGyN7Qtx99q6ZKlFMZ7QCeMRdsx YYIbBqP/OKsw9PJXnaJDIttW0dLNug/UgA== X-Google-Smtp-Source: APXvYqxoHi0TecnCLapRPstm0vZa00wzfV67S88Bm0/lP0qvZ4KyQqb2hK89Y802FzQ3wETbyCYzMg== X-Received: by 2002:a17:90a:9293:: with SMTP id n19mr2538094pjo.67.1573033757549; Wed, 06 Nov 2019 01:49:17 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id j11sm22249238pgk.3.2019.11.06.01.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 01:49:17 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCH 3/6] teamd/teamd_balancer.c: move teamd_log_dbg to teamd_log_dbgx Date: Wed, 6 Nov 2019 17:48:52 +0800 Message-Id: <20191106094855.13859-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20191106094855.13859-1-liuhangbin@gmail.com> References: <20191106094855.13859-1-liuhangbin@gmail.com> MIME-Version: 1.0 Message-ID-Hash: V63WHBYD7HV5EQGSEZPKFWSTB4FPDZET X-Message-ID-Hash: V63WHBYD7HV5EQGSEZPKFWSTB4FPDZET X-MailFrom: liuhangbin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Hangbin Liu , Jiri Pirko X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: As libdaemon do not filter log messages when we use syslog as output, all debug messages will be printed to the syslog even if we set daemon_verbosity_level to LOG_INFO. This would make user full confused and annoying. Since we have a -g option to enable debug message specially, let's move all teamd_log_dbg to teamd_log_dbgx so user could choose to print debug message or not. This patch will move all teamd_log_dbg to teamd_log_dbgx for teamd_balancer.c. I added a new parameter for function tb_hash_to_port_remap to get the ctx. Signed-off-by: Hangbin Liu --- teamd/teamd_balancer.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/teamd/teamd_balancer.c b/teamd/teamd_balancer.c index 25e8613..f9434c7 100644 --- a/teamd/teamd_balancer.c +++ b/teamd/teamd_balancer.c @@ -174,12 +174,14 @@ static void tb_clear_rebalance_data(struct teamd_balancer *tb) } } -static int tb_hash_to_port_remap(struct team_handle *th, +static int tb_hash_to_port_remap(struct teamd_balancer *tb, + struct team_handle *th, struct tb_hash_info *tbhi, struct tb_port_info *tbpi) { struct team_option *option; struct teamd_port *new_tdport = tbpi->tdport; + struct teamd_context *ctx = tb->ctx; uint8_t hash = tbhi->hash; int err; @@ -192,9 +194,9 @@ static int tb_hash_to_port_remap(struct team_handle *th, err = team_set_option_value_u32(th, option, new_tdport->ifindex); if (err) return err; - teamd_log_dbg("Remapped hash \"%u\" (delta %" PRIu64 ") to port %s.", - hash, tb_stats_get_delta(&tbhi->stats), - new_tdport->ifname); + teamd_log_dbgx(ctx, 1, "Remapped hash \"%u\" (delta %" PRIu64 ") to port %s.", + hash, tb_stats_get_delta(&tbhi->stats), + new_tdport->ifname); return 0; } @@ -203,6 +205,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th) int err; struct tb_hash_info *tbhi; struct tb_port_info *tbpi; + struct teamd_context *ctx = tb->ctx; if (!tb->tx_balancing_enabled) return 0; @@ -216,7 +219,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th) tbhi->rebalance.processed = true; continue; } - err = tb_hash_to_port_remap(th, tbhi, tbpi); + err = tb_hash_to_port_remap(tb, th, tbhi, tbpi); if (err) { tbpi->rebalance.unusable = true; continue; @@ -228,7 +231,7 @@ static int tb_rebalance(struct teamd_balancer *tb, struct team_handle *th) list_for_each_node_entry(tbpi, &tb->port_info_list, list) { if (tbpi->rebalance.unusable) continue; - teamd_log_dbg("Port %s rebalanced, delta: %" PRIu64, + teamd_log_dbgx(ctx, 1, "Port %s rebalanced, delta: %" PRIu64, tbpi->tdport->ifname, tbpi->rebalance.bytes); } return 0; @@ -303,8 +306,8 @@ static int tb_option_change_handler_func(struct team_handle *th, void *priv, array_index); return -EINVAL; } - teamd_log_dbg("stats update for hash \"%u\": \"%" PRIu64 "\".", - array_index, lb_stats->tx_bytes); + teamd_log_dbgx(ctx, 1, "stats update for hash \"%u\": \"%" PRIu64 "\".", + array_index, lb_stats->tx_bytes); tb_stats_update_hash(tb, array_index, lb_stats->tx_bytes); } @@ -319,7 +322,7 @@ static int tb_option_change_handler_func(struct team_handle *th, void *priv, port_ifindex); return -EINVAL; } - teamd_log_dbg("stats update for port %s: \"%" PRIu64 "\".", + teamd_log_dbgx(ctx, 1, "stats update for port %s: \"%" PRIu64 "\".", tdport->ifname, lb_stats->tx_bytes); tb_stats_update_port(tb, tdport, lb_stats->tx_bytes);