From patchwork Fri May 7 09:53:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38ED4C433ED for ; Fri, 7 May 2021 09:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0A3961059 for ; Fri, 7 May 2021 09:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236569AbhEGJyg (ORCPT ); Fri, 7 May 2021 05:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234242AbhEGJyg (ORCPT ); Fri, 7 May 2021 05:54:36 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C85CFC061574 for ; Fri, 7 May 2021 02:53:36 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id b17so9545891ede.0 for ; Fri, 07 May 2021 02:53:36 -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 :mime-version:content-transfer-encoding; bh=McwSnI8FYz6jCmF9mwg97pxJL8wFl9Qpv1eQNjFKRc8=; b=tEhVCvmd/pqoLtCPkTMK42Zse6kBMXIUFrUYpEzs23GdbZ1bnIY+Mls68a2F6RRY1P uudY2njDcpNrIYVv8z3x8MQHBjuXboHuP9ClgPx4J2KKDzjH4zqZH1nAxc+uKC0bSRu8 ANYyzZe2ncVx1T00HwlfyPr94r2FzM90a/VwAatv4LJ6uPheN7rxfE8hhQUCZQgL3pG2 subFYxs1uZ6EvD7gQ+oxmv4XmZ/xPG6lJh64zVVa5e6GC0xN85u2/JxLtmow/+FNhCRZ 8k1feEwAdgcrxJJYbdgpW0FNcr2WkG672Sz2wv9xckU/ChbJvysT+DrV6mmz2upZ+OUO CYiw== 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=McwSnI8FYz6jCmF9mwg97pxJL8wFl9Qpv1eQNjFKRc8=; b=NMAqO6WKygGEXvvYYX3RtbUXrHd7tFD6WqXeHjsQ1JILpcJls9CgmOsShhijlLcB4m NAFVme5pSkfn20qCEYWi/gCB73UbdshaSKqlwXyduMH3TIqDc9TeJxp2gx8iYwJ7CagL QS5NPyDzELSOBiS5HBJgFqMCiysnuO0pggOZeyI8JyT8EtZ5xHbNxNya3wuRCoSx5IfA 11KHoFsQZcfLyVgtBnoSh/9UHvBpwZhyP08GxsHzg3g2hmuh5hCSu6s/POs+VUD2BRoL CKxM66rifCVgzV5C8vem4ctZElGZB3g/uOuwwTBprGBcZJ6eSOKDaEgQlR8JM9CIxFMx 4diw== X-Gm-Message-State: AOAM531oW6LPly+M24kFsXKSm7cnR0NX+O4AEwUD6SzuYsGSzvvXLA2X wbAmPad3QFarq520Qck2q2dnp8RgWBeHOQ== X-Google-Smtp-Source: ABdhPJxVhNaRgGp3H2ADTcuaUmuwVnN/G13cm4v7LWig9At2jZfr/IU65k7+XAD1CQoCrmJ3LZRESw== X-Received: by 2002:aa7:cf19:: with SMTP id a25mr10485805edy.231.1620381215585; Fri, 07 May 2021 02:53:35 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:35 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 1/8] trace-cmd library: Use tep_vprint() for logs Date: Fri, 7 May 2021 12:53:26 +0300 Message-Id: <20210507095333.1080910-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The traceevent library funciton for printing logs is changed from tep_vwarning to tep_vprint. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/trace-util.c | 5 +++-- python/ctracecmd.i | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 2d3bc741..ab77ce2a 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "trace-cmd-private.h" @@ -359,7 +360,7 @@ void __weak tracecmd_warning(const char *fmt, ...) va_list ap; va_start(ap, fmt); - tep_vwarning("libtracecmd", fmt, ap); + tep_vprint("libtracecmd", TEP_LOG_WARNING, true, fmt, ap); va_end(ap); } @@ -369,7 +370,7 @@ void __weak tracecmd_fatal(const char *fmt, ...) va_list ap; va_start(ap, fmt); - ret = tep_vwarning("libtracecmd", fmt, ap); + ret = tep_vprint("libtracecmd", TEP_LOG_CRITICAL, true, fmt, ap); va_end(ap); if (debug) { diff --git a/python/ctracecmd.i b/python/ctracecmd.i index e938c780..7091b9bd 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -63,7 +63,7 @@ void warning(const char *fmt, ...) return; va_start(ap, fmt); - tep_vwarning("tracecmd", fmt, ap); + tep_vprint("tracecmd", TEP_LOG_WARNING, true, fmt, ap); va_end(ap); } From patchwork Fri May 7 09:53:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AE8FC43460 for ; Fri, 7 May 2021 09:53:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDE49613D6 for ; Fri, 7 May 2021 09:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236592AbhEGJyh (ORCPT ); Fri, 7 May 2021 05:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234242AbhEGJyh (ORCPT ); Fri, 7 May 2021 05:54:37 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D17BEC061574 for ; Fri, 7 May 2021 02:53:37 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id y26so9510903eds.4 for ; Fri, 07 May 2021 02:53:37 -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 :mime-version:content-transfer-encoding; bh=lZHQOdRyIHk2MaqzgxDCIBcBIVFMyPrrgwagy00c46g=; b=OxyXPQ8PFkm0UeWuabzLAJ6GaPd3RwiDUF8jWuOJ/eJ+vtMa9px8tq+MOq7jnRihM1 rl7injI2WCdlg1XjTzxKS6dPVoz52IsUFBwWO7xFnsM4XAo18J6SdzX47Qx2nUUkWebJ R/Y8RjtzGozL0BjOU0E+ojvdFIFFRoSP26g7WA7pwX/7wj4MVnn/DIfFjseIoHgWo4yR th8Kpjs8mKGbdD6hEyCEiJfi/E1QdbPb/pobo6T74lzbHqfgF9l3XvXuVJvkl8yohYI6 TZq5x9g/+2wehhqBG8l+zq8yaTzCXPJnRiYc8BJkRC5TOjpEuYarw7qPQ/iiOC1FT7Sa hf2g== 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=lZHQOdRyIHk2MaqzgxDCIBcBIVFMyPrrgwagy00c46g=; b=JV8xYKVyujdFFfx8uimPhZuC2omx2kr5cJmhdNuAwTqEem7wPdjexg5B0uCqD9KExE Bpn1q10HVuedszOR77Y+2D72BynAeoD2qB06kRM7yMKFSEu365nIo+nGMbKB+brakJ6S /SiMhenuXqEhYDztci0Fw5K3eY2uCWpJant7smTCNomVEBHbrmOtFzdAFC8vNQmZCgDR njXrXc0eEFJk/fAfsgVvTAxMQ85LSRFhc+DiBnaKBr9xLPkU8vQsp+7tGRdAoH2h8hRG vUBQCCX94d4kWwlOYqJsnwnxvwfYJ2Wgbl2DMIgeUSMXuII/MMPQ6E+wAYNvCY1qydug fecA== X-Gm-Message-State: AOAM531OO88adRTKWrka82vCTKU4uuQaLM1XdE+9WP+dn2cO/myb5/6z EzK8TtMDFqn+U9lFa9JI9PQ= X-Google-Smtp-Source: ABdhPJzXilRfPLMtOWpPZ5AqY0ZJuU1DBw4kz4pbAfkm7cX6uB2huo8AYcTViWwrz3qc1WZDXAZASA== X-Received: by 2002:a05:6402:26d1:: with SMTP id x17mr10359025edd.14.1620381216607; Fri, 07 May 2021 02:53:36 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:36 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 2/8] trace-cmd library: Add tracecmd_info() log function Date: Fri, 7 May 2021 12:53:27 +0300 Message-Id: <20210507095333.1080910-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The pr_stat() function is removed from the traceevent library. This function was used by trace-cmd to print statistics. Introduced tracecmd_info() log function and replaced pr_stat() with it in the trace-cmd library. However, pr_stat() is used also in the trace-cmd application. In order no to change the existing behaviour, added a static pr_stat() implementation for that usage. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/include/trace-cmd-local.h | 1 + lib/trace-cmd/trace-input.c | 2 +- lib/trace-cmd/trace-plugin.c | 2 +- lib/trace-cmd/trace-util.c | 10 ++++++++++ python/ctracecmd.i | 11 ----------- tracecmd/trace-cmd.c | 14 -------------- tracecmd/trace-record.c | 14 ++++++++++++++ 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index e8533b22..cd868f60 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -12,6 +12,7 @@ /* Can be overridden */ void tracecmd_warning(const char *fmt, ...); void tracecmd_fatal(const char *fmt, ...); +void tracecmd_info(const char *fmt, ...); /* trace.dat file format version */ #define FILE_VERSION 6 diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 9726e994..2e519752 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -3292,7 +3292,7 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd, int flags) version = read_string(handle); if (!version) goto failed_read; - pr_stat("version = %s\n", version); + tracecmd_info("version = %s\n", version); free(version); if (do_read_check(handle, buf, 1)) diff --git a/lib/trace-cmd/trace-plugin.c b/lib/trace-cmd/trace-plugin.c index ca7cadae..50c800c2 100644 --- a/lib/trace-cmd/trace-plugin.c +++ b/lib/trace-cmd/trace-plugin.c @@ -140,7 +140,7 @@ load_plugin(struct trace_plugin_context *trace, const char *path, list->name = plugin; *plugin_list = list; - pr_stat("registering plugin: %s", plugin); + tracecmd_info("registering plugin: %s", plugin); func(trace); return; diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index ab77ce2a..049fe049 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -364,6 +364,16 @@ void __weak tracecmd_warning(const char *fmt, ...) va_end(ap); } +void tracecmd_info(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + tep_vprint("libtracecmd", TEP_LOG_INFO, false, fmt, ap); + va_end(ap); +} + + void __weak tracecmd_fatal(const char *fmt, ...) { int ret; diff --git a/python/ctracecmd.i b/python/ctracecmd.i index 7091b9bd..6d0179e3 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -44,17 +44,6 @@ static void py_supress_trace_output(void) skip_output = 1; } -void pr_stat(const char *fmt, ...) -{ - va_list ap; - - if (skip_output) - return; - va_start(ap, fmt); - __vpr_stat(fmt, ap); - va_end(ap); -} - void warning(const char *fmt, ...) { va_list ap; diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c index 7376c5a5..60cd3ea1 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -35,20 +35,6 @@ void warning(const char *fmt, ...) fprintf(stderr, "\n"); } -void pr_stat(const char *fmt, ...) -{ - va_list ap; - - if (!show_status) - return; - - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - - printf("\n"); -} - void *malloc_or_die(unsigned int size) { void *data; diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 5dd8be4a..274d706c 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -2934,6 +2934,20 @@ static void test_event(struct event_list *event, const char *path, *save = event; } +static void pr_stat(const char *fmt, ...) +{ + va_list ap; + + if (!show_status) + return; + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + + printf("\n"); +} + static int expand_event_files(struct buffer_instance *instance, const char *file, struct event_list *old_event) From patchwork Fri May 7 09:53:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DC28C43461 for ; Fri, 7 May 2021 09:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55DE1613D6 for ; Fri, 7 May 2021 09:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236599AbhEGJyo (ORCPT ); Fri, 7 May 2021 05:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236866AbhEGJyo (ORCPT ); Fri, 7 May 2021 05:54:44 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8221BC061761 for ; Fri, 7 May 2021 02:53:43 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id n15so4888436edw.8 for ; Fri, 07 May 2021 02:53:43 -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 :mime-version:content-transfer-encoding; bh=atjZ/yiZiHgCaYm70jJ4k62FlJxalnCDG6n7ncN5BNU=; b=Yp+QBNEHNO17uLSts81/rgUmC+yJEuwNc2O639fWW83Y/5NXkE+1BtsX7p+MJxLIHC 0otOFYkmIqgbqkjOMWXL2p2/euoWKUqlgOG07Fv2oUbPArTgeZVIUHGkh2YyUMiiKMY9 f8Fj6Z9uwcl67GccnCoIAK4C9wzmAqEW4/coIGkmmDKN+eBRw7AVSw4GUG0Tk3fR/oES sw0yM5a6n4/Ukhs348jJjri575Zc4b0ZkPc5oFsMwXUX84EPElGdUQLRnYHNi3+UNhJX sreuH3QDeZXNmFV0dv+gGExrZ77dGD67To9FhK/X1WudxvnfRKyG6+szH142ZNSRrLpO Vf6w== 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=atjZ/yiZiHgCaYm70jJ4k62FlJxalnCDG6n7ncN5BNU=; b=KK68iuyBBrlgNn5sDUC3m4qIB4/trmZ0gW8DdwMtT2iLW9h9uJYG6ykJtsv50IJaki udHzkVxQYBcnitxXjlQNXmXp3Fx8uRpiGdd+nyTjho344qt3BluR8DczAt8OUydpRpfV Zaq4gp/8W8JoIa7A/wEl3ZTp6KGZJp0wlliV8g9307DCwtY8f1XgdZ4+KomhkEsC4jXZ wPnYW1CJQbGkSQ7bIfitf/DNQp3xAxQtu+IXRYRIAhLP3WmxkPcZPA+deJwHR4rrXdYk n64TrJBeHUd0mZx1LTcn7/SWTX5lu76bC9hc0/261JJVj3feebMGZx2wB4avmUIu6EJK pt/Q== X-Gm-Message-State: AOAM532xAMkUJ0uqCKtaE2JzPCbPP0ohx9ZVDWlZLLhiWko8amTTCW6w HJrQnROe28hW+7C+OqC+CkA= X-Google-Smtp-Source: ABdhPJxqP19TdAyg3Y6TRJQYGkvPHPgiahq7Nfd+DhV8Ks4NPn3hWS6VR3g9HFztwbc+SF1qfzju2A== X-Received: by 2002:a05:6402:26ce:: with SMTP id x14mr10184768edd.216.1620381217404; Fri, 07 May 2021 02:53:37 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:37 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 3/8] trace-cmd library: Add log levels Date: Fri, 7 May 2021 12:53:28 +0300 Message-Id: <20210507095333.1080910-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Add levels to library logs and introduce a new API to set the desired log severity: tracecmd_set_loglevel() When a new trace-cmd library log level is set, propagate it to tracefs and traceevent libraries as well. Removed the "weak" definition of the library log functions. Setting the desired log level can be used to silence the library logs, instead of overwriting the log functions. Signed-off-by: Tzvetomir Stoyanov (VMware) --- include/trace-cmd/trace-cmd.h | 2 ++ lib/trace-cmd/include/trace-cmd-local.h | 1 - lib/trace-cmd/trace-util.c | 26 ++++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h index 7305487c..6984db86 100644 --- a/include/trace-cmd/trace-cmd.h +++ b/include/trace-cmd/trace-cmd.h @@ -43,4 +43,6 @@ int tracecmd_buffer_instances(struct tracecmd_input *handle); const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx); struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx); +void tracecmd_set_loglevel(enum tep_loglevel level); + #endif /* _TRACE_CMD_H */ diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index cd868f60..76179148 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -9,7 +9,6 @@ #include #include "trace-cmd-private.h" -/* Can be overridden */ void tracecmd_warning(const char *fmt, ...); void tracecmd_fatal(const char *fmt, ...); void tracecmd_info(const char *fmt, ...); diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 049fe049..b3f1b075 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -30,7 +30,7 @@ #define PROC_STACK_FILE "/proc/sys/kernel/stack_tracer_enabled" static bool debug; - +static int log_level = TEP_LOG_CRITICAL; static FILE *logfp; const static struct { @@ -355,10 +355,24 @@ trace_load_plugins(struct tep_handle *tep, int flags) return list; } -void __weak tracecmd_warning(const char *fmt, ...) +/** + * tracecmd_set_loglevel - set log level of the library + * @level: desired level of the library messages + */ +void tracecmd_set_loglevel(enum tep_loglevel level) +{ + log_level = level; + tracefs_set_loglevel(level); + tep_set_loglevel(level); +} + +void tracecmd_warning(const char *fmt, ...) { va_list ap; + if (log_level < TEP_LOG_WARNING) + return; + va_start(ap, fmt); tep_vprint("libtracecmd", TEP_LOG_WARNING, true, fmt, ap); va_end(ap); @@ -368,17 +382,23 @@ void tracecmd_info(const char *fmt, ...) { va_list ap; + if (log_level < TEP_LOG_INFO) + return; + va_start(ap, fmt); tep_vprint("libtracecmd", TEP_LOG_INFO, false, fmt, ap); va_end(ap); } -void __weak tracecmd_fatal(const char *fmt, ...) +void tracecmd_fatal(const char *fmt, ...) { int ret; va_list ap; + if (log_level < TEP_LOG_CRITICAL) + return; + va_start(ap, fmt); ret = tep_vprint("libtracecmd", TEP_LOG_CRITICAL, true, fmt, ap); va_end(ap); From patchwork Fri May 7 09:53:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4938C433B4 for ; Fri, 7 May 2021 09:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE43061059 for ; Fri, 7 May 2021 09:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234242AbhEGJyk (ORCPT ); Fri, 7 May 2021 05:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236599AbhEGJyk (ORCPT ); Fri, 7 May 2021 05:54:40 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8CE5C061574 for ; Fri, 7 May 2021 02:53:39 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id s20so7180516ejr.9 for ; Fri, 07 May 2021 02:53:39 -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 :mime-version:content-transfer-encoding; bh=MhaNQMLEk3FzjpKjnPZiq4qO19h0lLl+kHtcI51ICRM=; b=E27sU9jlYVLP9rsqG9h3yGyHjrux/hdaangjbBafY4vgaQ7eB/qR9e6VFjWO5eRpvb zb2auFYjkkHsw/otPWSsAFrWU/b8unZT9oydUG5w2oAMjJzhomx3fhzokw76h3RYKnDT hNy1aR3Dz76MOVWEXDFNpu+Vue5qcI4O+Ewl+SMNYl2LxPnnSF1CIEN6ZGHigP3hc4SZ FqrRmoh7fgdALYCc6B2T6AuQV4MptpcRVuy8XllcFZ1N26dpuw1Ywr76LeFRdUT4fF68 DNSUXKeKUO1BemTwEKZDfQKyEvieCKUagherCLUdgGZOQ9Nkb55GhqHftGoicibaLgtT Fw9A== 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=MhaNQMLEk3FzjpKjnPZiq4qO19h0lLl+kHtcI51ICRM=; b=iDgHDte/Zz30XybVtsHue6YVfR7vfnDcsTLE3pjRGYj7sFRhcnqR4uUVhh293/6v79 Eb9N6Z0FgfpUnb52TcyFgnfoSDj6+qTOVKBBjJZ+k7cA2faqTlqOp56IlAeVM04zb58u s0+glPEicm+lxjHBhC2ptZnjS3dRPcMLainB3pVS+RWf3PjK112MKHmEK42Qy3gIewkb wLsKk2aVk7d4unaHUoMah82KVSXkaklM4UWhH3cRq6cSb/fK2DZ1sSqtj8O8YMhh5k1A mBN7xYE39ewRbGOSGBglYapQa6H/MK4nAVZX31GtvpevNgHBlsFrnc3QGc0nPYe/tosd LIhw== X-Gm-Message-State: AOAM530P0q+GwjNAzAeP14KmmNokDYidrRl1SvsYCe46rOTTl7pZIP+a 2rS0ZCg3yDm1oyanYEiMBZg= X-Google-Smtp-Source: ABdhPJxqrsHBjfwzyiSVvrr8lzF4XfibQkEKMYK5afGEm2wktC+CvN2PUICGZUNRJRSvo7CZbJtTBQ== X-Received: by 2002:a17:906:c14c:: with SMTP id dp12mr8887113ejc.312.1620381218390; Fri, 07 May 2021 02:53:38 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:37 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 4/8] trace-cmd library: Document the API for log levels Date: Fri, 7 May 2021 12:53:29 +0300 Message-Id: <20210507095333.1080910-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Updated trace-cmd library man pages with description of the API for setting the library log levels: tracecmd_set_loglevel() Signed-off-by: Tzvetomir Stoyanov (VMware) --- Documentation/libtracecmd/libtracecmd-log.txt | 78 +++++++++++++++++++ Documentation/libtracecmd/libtracecmd.txt | 3 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/libtracecmd/libtracecmd-log.txt diff --git a/Documentation/libtracecmd/libtracecmd-log.txt b/Documentation/libtracecmd/libtracecmd-log.txt new file mode 100644 index 00000000..de5c2776 --- /dev/null +++ b/Documentation/libtracecmd/libtracecmd-log.txt @@ -0,0 +1,78 @@ +libtracecmd(3) +============= + +NAME +---- +tracecmd_set_loglevel - Set log level of the library + +SYNOPSIS +-------- +[verse] +-- +*#include * + +int *tracecmd_set_loglevel*(enum tep_loglevel _level_); +-- + +DESCRIPTION +----------- +The _tracecmd_set_loglevel()_ function sets the level of the library logs that will be printed on +the console. See _libtraceevent(3)_ for detailed desciription of the log levels. Setting the log +level to specific value means that logs from the previous levels will be printed too. For example +_TEP_LOG_WARNING_ will print any logs with severity _TEP_LOG_WARNING_, _TEP_LOG_ERROR_ and +_TEP_LOG_CRITICAL_. The default log level is _TEP_LOG_CRITICAL_. When a new level is set, it is +also propagated to the libtracefs and libtraceevent. + +EXAMPLE +------- +[source,c] +-- +#include +... +tracecmd_set_loglevel(TEP_LOG_ALL); +... +/* call libtracecmd, libtracefs or libtraceevent APIs and observe any logs they produce */ +... +tracecmd_set_loglevel(TEP_LOG_CRITICAL); +-- + +FILES +----- +[verse] +-- +*trace-cmd.h* + Header file to include in order to have access to the library APIs. +*-ltracecmd* + Linker switch to add when building a program that uses the library. +-- + +SEE ALSO +-------- +_libtracefs(3)_, +_libtraceevent(3)_, +_trace-cmd(1)_ +_trace-cmd.dat(5)_ + +AUTHOR +------ +[verse] +-- +*Steven Rostedt* +*Tzvetomir Stoyanov* +-- +REPORTING BUGS +-------------- +Report bugs to + +LICENSE +------- +libtracecmd is Free Software licensed under the GNU LGPL 2.1 + +RESOURCES +--------- +https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/ + +COPYING +------- +Copyright \(C) 2021 VMware, Inc. Free use of this software is granted under +the terms of the GNU Public License (GPL). diff --git a/Documentation/libtracecmd/libtracecmd.txt b/Documentation/libtracecmd/libtracecmd.txt index adc9321c..dc528ce0 100644 --- a/Documentation/libtracecmd/libtracecmd.txt +++ b/Documentation/libtracecmd/libtracecmd.txt @@ -33,6 +33,9 @@ Read tracing instances from a trace file: Get traceing peer information from a trace file: unsigned long long *tracecmd_get_traceid*(struct tracecmd_input pass:[*]_handle_); int *tracecmd_get_guest_cpumap*(struct tracecmd_input pass:[*]_handle_, unsigned long long _trace_id_, const char pass:[*]pass:[*]_name_, int pass:[*]_vcpu_count_, const int pass:[*]pass:[*]_cpu_pid_); + +Control library logs: + int *tracecmd_set_loglevel*(enum tep_loglevel _level_); -- DESCRIPTION From patchwork Fri May 7 09:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FD44C433ED for ; Fri, 7 May 2021 09:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3608661059 for ; Fri, 7 May 2021 09:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236618AbhEGJyk (ORCPT ); Fri, 7 May 2021 05:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234242AbhEGJyk (ORCPT ); Fri, 7 May 2021 05:54:40 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E47C061761 for ; Fri, 7 May 2021 02:53:40 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id u13so9512202edd.3 for ; Fri, 07 May 2021 02:53:40 -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 :mime-version:content-transfer-encoding; bh=wF8u9Jrym8Q2KVTiI435kCIiqYjj3/Tg6jcIA91IEqo=; b=vVQrDZ8OyL7OJcc2xEcYs+j/W4LtfKG9G4bQJZn0imIjwwFrXohN6EILaACDZiyiWR zCGKy+fAUW2Xw4CsM7AAQpGfnLjd+ezn+mEiQI6t4FO1hv0niNAMrvc4dKYpI+Sh6HOC ZN7BmhzvgjWWJmBFjw2HFAPKRIrAtxahmRgjFc3VhsKEZy2QjQSt0YCa1Zj3YdZCkvm2 yJcELAlVvywL0FBdOxnd4MVkGQE2te1VAnCFzJlQ54kVrAV06Bu31v8+GMEdkqd9ORp2 TDsFuuEOI9tnVbX29zQeac4Apk14yZvzXuEmmKNwK+h6NHKIkWccp30i84GDErF0c6Yf f92g== 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=wF8u9Jrym8Q2KVTiI435kCIiqYjj3/Tg6jcIA91IEqo=; b=HCIVbt7O3el8vDa3/Y/llYAU85lksq3Wfgu5zkAQ09MLr1K5HIUvyaAw6AsGbEmxXm aspBqfY88lR5UmIxJxzRHLE+HM/1YTVciv06HeeMrKCMi5rdEi2rzrZQeZ0uiLP98JB6 /iPlxuyZ9VAfCq6gnvSO9naCdvExv1BArpazjnCBHvahVKjh6Lzh3OZX1C7d+MwVe6e5 xk/KI2Gj97MrWV8+m6GWpGn85OKDsm2NfN5gtAZALZuqmvINpTeNmh6pSqffCPWqx+se 0DugndNt14cnzTXms6plJwcxkEXTf2IFdpmQUcbnQhVgc1cc+Wkt4GvwfA0f/+VJ8Vsc oYKw== X-Gm-Message-State: AOAM5308PsoI1wDS+1/klYkHT1WWghaNxXVT0OcT6xcNLcZpnGZWQUjN WQaIeJOFy0rIOU1LtD1GA2A= X-Google-Smtp-Source: ABdhPJzfnfYS4oARpCWNrOiIOIm2UFDd3LDleeiyZd50jvOvYz0WIW9jpleS1D8+F/pwOy2qH/XdEQ== X-Received: by 2002:a50:c44f:: with SMTP id w15mr10486599edf.79.1620381219382; Fri, 07 May 2021 02:53:39 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:38 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 5/8] trace-cmd library: Renamed tracecmd_fatal() to tracecmd_critical() Date: Fri, 7 May 2021 12:53:30 +0300 Message-Id: <20210507095333.1080910-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The trace-cmd library function for pritning critical logs is renamed from tracecmd_fatal() to tracecmd_critical() to be consistent with the names of the log levels. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/include/trace-cmd-local.h | 2 +- lib/trace-cmd/trace-input.c | 12 ++++++------ lib/trace-cmd/trace-util.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index 76179148..7bf620d4 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -10,7 +10,7 @@ #include "trace-cmd-private.h" void tracecmd_warning(const char *fmt, ...); -void tracecmd_fatal(const char *fmt, ...); +void tracecmd_critical(const char *fmt, ...); void tracecmd_info(const char *fmt, ...); /* trace.dat file format version */ diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 2e519752..5ee69b14 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -1105,7 +1105,7 @@ static void __free_page(struct tracecmd_input *handle, struct page *page) int index; if (!page->ref_count) { - tracecmd_fatal("Page ref count is zero!\n"); + tracecmd_critical("Page ref count is zero!\n"); return; } @@ -1166,7 +1166,7 @@ void tracecmd_free_record(struct tep_record *record) return; if (!record->ref_count) { - tracecmd_fatal("record ref count is zero!"); + tracecmd_critical("record ref count is zero!"); return; } @@ -1176,7 +1176,7 @@ void tracecmd_free_record(struct tep_record *record) return; if (record->locked) { - tracecmd_fatal("freeing record when it is locked!"); + tracecmd_critical("freeing record when it is locked!"); return; } @@ -1375,7 +1375,7 @@ static int get_page(struct tracecmd_input *handle, int cpu, if (offset & (handle->page_size - 1)) { errno = -EINVAL; - tracecmd_fatal("bad page offset %llx", offset); + tracecmd_critical("bad page offset %llx", offset); return -1; } @@ -1383,7 +1383,7 @@ static int get_page(struct tracecmd_input *handle, int cpu, offset > handle->cpu_data[cpu].file_offset + handle->cpu_data[cpu].file_size) { errno = -EINVAL; - tracecmd_fatal("bad page offset %llx", offset); + tracecmd_critical("bad page offset %llx", offset); return -1; } @@ -1949,7 +1949,7 @@ tracecmd_peek_data(struct tracecmd_input *handle, int cpu) record = handle->cpu_data[cpu].next; if (!record->data) { - tracecmd_fatal("Something freed the record"); + tracecmd_critical("Something freed the record"); return NULL; } diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index b3f1b075..3b2a9183 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -390,8 +390,7 @@ void tracecmd_info(const char *fmt, ...) va_end(ap); } - -void tracecmd_fatal(const char *fmt, ...) +void tracecmd_critical(const char *fmt, ...) { int ret; va_list ap; @@ -560,7 +559,7 @@ int tracecmd_count_cpus(void) fp = fopen("/proc/cpuinfo", "r"); if (!fp) { - tracecmd_fatal("Can not read cpuinfo"); + tracecmd_critical("Can not read cpuinfo"); return 0; } From patchwork Fri May 7 09:53:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2704DC433ED for ; Fri, 7 May 2021 09:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEE876145D for ; Fri, 7 May 2021 09:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236640AbhEGJym (ORCPT ); Fri, 7 May 2021 05:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236636AbhEGJyl (ORCPT ); Fri, 7 May 2021 05:54:41 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5DEC061761 for ; Fri, 7 May 2021 02:53:41 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id b17so9546149ede.0 for ; Fri, 07 May 2021 02:53:41 -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 :mime-version:content-transfer-encoding; bh=cIYSV+Nn83OaVWLnEwvJcj4u82LxV3VibYgN2+ygPgY=; b=jYO+FIKHQvcxrY8zFMQjql5EYFEQvoSAvc9NtunbYsJxLUZxDc0qMZNxT0DvCqHFWc RSdfS6NuUyIWGQPXTbNbUryaFgNM20nCS6QBGqO8MfoKhUQHGwkVUzOvTbQZBi9s58n/ kkY26bS665BOvl/N/JH/G61FYm/VPq/47XlL7sVD7uPqrK16D16TtFDOXrYY2iUZ1yja k2TjnAH0smN5paTiWiw6hKcTxJKuO2UhFQMQR1OqtL9ydWmB9aEzxoIvEFMG9p88e23q MyAXEkJV3v7K5BDzP5AYE+zaWhZW9wm8MWTqECbti/Rf3hbuk+saqULcCTW2Yayb6JPY Dh2A== 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=cIYSV+Nn83OaVWLnEwvJcj4u82LxV3VibYgN2+ygPgY=; b=ovUDJ29I9v1ycrbDv6byvNMinCJQTdDtYDPoY5WcoFbIoEch0qOCYHQrO6UJNXLhvp 42cC55x6s5ig5JoV5F8p3cqLjqWB/OVxwL6gnHkkCgfhvqlHVNiztafFjN44bEBWmIwn A/jmjWUO6xv5us/BMLxe2FLFtGOlAm+620uGA/Aqo2dhmWnMIJNLTV8iwPP339P7JALS QUjKIDWZf/OoxshOjS9yQt6D1+6UGMuc2cPYvqtH6Wn2k8hz251YrnikgFeZi0OhoJuP ouZslIt4DRQdUELFHyMIrnLioV3V1e9t6Get4VD7xMN588a3A6wnVIPSQQqJYyNDa2bu /NQg== X-Gm-Message-State: AOAM531KyFUlcy1dhgoDm2qZP3p80nZZTmWmzCPlcIFhz0wZQ+eCKHfW vhjfzVM2QQ8dcUcBO+zaSa6jcMRxsX2Fxg== X-Google-Smtp-Source: ABdhPJzgkg3Y4058+R6kgc/apmfyayP04+jqgoF9d3Nq51URY3Pb4gdLaC7esiJwp2xswP0mTwMI/g== X-Received: by 2002:a05:6402:d05:: with SMTP id eb5mr10231237edb.6.1620381220366; Fri, 07 May 2021 02:53:40 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:39 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 6/8] trace-cmd library: Set debug log level in debug mode Date: Fri, 7 May 2021 12:53:31 +0300 Message-Id: <20210507095333.1080910-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org When the library works in debug mode, set the log level to debug. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/trace-util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 3b2a9183..995f5786 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -93,6 +93,11 @@ const char *tracecmd_clock_id2str(enum tracecmd_clocks clock) void tracecmd_set_debug(bool set_debug) { debug = set_debug; + + if (set_debug) + tracecmd_set_loglevel(TEP_LOG_DEBUG); + else + tracecmd_set_loglevel(TEP_LOG_CRITICAL); } /** From patchwork Fri May 7 09:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2EDBC433B4 for ; Fri, 7 May 2021 09:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8039613D6 for ; Fri, 7 May 2021 09:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236867AbhEGJyo (ORCPT ); Fri, 7 May 2021 05:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236599AbhEGJym (ORCPT ); Fri, 7 May 2021 05:54:42 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7563FC061574 for ; Fri, 7 May 2021 02:53:42 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id f24so12675471ejc.6 for ; Fri, 07 May 2021 02:53:42 -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 :mime-version:content-transfer-encoding; bh=z0LcYKshq465WgeE8dPD2Nn0zo3Dp6s7Ui2Y7fj6Jpk=; b=s4RYRCE0LPwhEck40T3dYENjz4UrTm2LzWLxGv8rRIBK5t9BA3ktFPyzxYUFVQKswI BFQgVDYg04k17KLrNbikoUeztWE5yw0tQSRKh1L7bUVroJ6mot6nBn46Q4Oq1kSm31ic UyVIwHiOgLAd4w1WUao9nHepvSf4DuRk8B2BFXigVGF4EnyJ/YfhfniTplSc0+nB3/Hf DdZ7tO+BCMNRIyik6uGChCNhHfpij9cQGjRe7LD6bTwNmbqXCq0y1l2qEga1uVveyIXb NOU6XEaEk3YmnmoaO+t5ZMIxEFfRfQK4EKLjKuHfflvnlhNdBEEp+pQBaj3zO/AnAyi+ W43Q== 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=z0LcYKshq465WgeE8dPD2Nn0zo3Dp6s7Ui2Y7fj6Jpk=; b=FpYVPRTCmpg7Kd/fKuClxzy7S7Xh39J2NVHOXz17cpjzzunaB766bbWz654i/QQLYD LYC0/EdM10LlOBC8TNHbLUlmkXERbDBOBSIw5nInAGRiNZKbucrkZekafuk/8mBfVLIX FJk99KsvBU8W3LonW98G7TnIS0+FHeS7MD9U4wuAbj7ZUNyjeFYJVNNdXW6PIlYmTT2t eu1cgdB9twDYTsFJvKFEJeEQzVmtnCH8mgzOEcWWl6aVkVdPix7q/3yUF654Ag1H9XqQ alwYKJRYMjni7cB1LrK2Gz6LUPRvH43wNFpDl1aMLV9IWO4mtvA5w+RrkTENxOmVj6Cm ku1g== X-Gm-Message-State: AOAM530oknKCYDwMtSe0epP0U/1jGj1Qpxc8Er9sdjrdwfNnyNOU+iRV CqCmdXxYMyxbiIYQk9EO3PkCH1CT+3hm9A== X-Google-Smtp-Source: ABdhPJw77PetzbymOZ49MKp62E5xotCN06x7tmUN1UMyJvzrxa6M6Mtqaes8RIjQ8Z4UgOC4s32WnQ== X-Received: by 2002:a17:906:58d1:: with SMTP id e17mr9253504ejs.179.1620381221259; Fri, 07 May 2021 02:53:41 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:40 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 7/8] trace-cmd report: Set the log level with -V and -q options Date: Fri, 7 May 2021 12:53:32 +0300 Message-Id: <20210507095333.1080910-8-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org When "trace-cmd report -V" is specified, set the log level to INFO. When "trace-cmd report -q" is specified, set the log level to NONE. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-read.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index b315283e..0cf6e773 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -1703,9 +1703,11 @@ void trace_report (int argc, char **argv) break; case 'V': show_status = 1; + tracecmd_set_loglevel(TEP_LOG_INFO); break; case 'q': silence_warnings = 1; + tracecmd_set_loglevel(TEP_LOG_NONE); break; case OPT_cpu: parse_cpulist(optarg); From patchwork Fri May 7 09:53:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12244259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B101DC43462 for ; Fri, 7 May 2021 09:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A85C6145E for ; Fri, 7 May 2021 09:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236866AbhEGJyp (ORCPT ); Fri, 7 May 2021 05:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236636AbhEGJyo (ORCPT ); Fri, 7 May 2021 05:54:44 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C40C061574 for ; Fri, 7 May 2021 02:53:43 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id zg3so12693571ejb.8 for ; Fri, 07 May 2021 02:53:43 -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 :mime-version:content-transfer-encoding; bh=g0vdklY04kD2npqSKc0g6BwKJeXmFQKNuUMCw4azhOE=; b=auzf7pi7v/6Z0cQIcMOxxYzDjknQ0WnfjHam6J2geIcMFiZwXAKKHllxn3YIGWKhpr jOxrL9X3d4vaXlrfR6CAyk7fU4BXJN2N+NYH8sFyzYCVIqj6cYlOWJNMdFRW/AV/DmSG HlcEpz1RGCGFsbTdB8mDsbx3kVITUz9DyAc9h0EaDWKOhz24ZKzO+fP/atlcM9rpJKze 5IcySwZ3C+qbfF72el72jvxQnAQGEDJ12e4PnppuV7BjOef3UCfMudkds0GmoUqA5V0d Zhxdfk9dw8i0RGf1Ed8PKKtkhkq/UeuewGnSLDfG5VQaO2Q651xDaYOgFcV1pgq7uv2g utGg== 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=g0vdklY04kD2npqSKc0g6BwKJeXmFQKNuUMCw4azhOE=; b=nBE6TLDbQR+ODcx9yV1QHvnpLA+ro25gtqGwtjebUFlWGEde0fQykzN1cxFVGtU+UW h1Pmfc9U4fKIhAvwcgUHs8GVcCnl5AQneN3zquWJGPGsW1PtZPMFaDdL+bM7tTz/pPwe blSwt4UmczpN7qgFFRjjEBa9PYbGxfmG5VVEiRlYITWVidJhchacRvI+uaB0sWB0HW+Y 1EKgc3ekeHjt/zKlckwlC4i8Kxp8OJlIi9eXviFrseex8b4oMlendTXGrvlCY74BvPDU oQGNA7vs9pGVrzYfgP7iDr/1HX/hetRv94VlAipADdJ6AJcu6bOe4CN4ziQxu3iSWN56 FHOg== X-Gm-Message-State: AOAM531xy1BYiV3Aa7G/3pKycEnMJ+1w/DNbC41FP95iKsAe8fnCkSoN +n2Xb7dtKZN8iaDjK9SxRlc= X-Google-Smtp-Source: ABdhPJwtAZefgOZm1zCMM1KOgmuzFyq+Eu6oJqasEWi5VZzXoZPnBAcrLO3xAfvIKmFgDVaHQKuuIQ== X-Received: by 2002:a17:906:5791:: with SMTP id k17mr8871331ejq.296.1620381222683; Fri, 07 May 2021 02:53:42 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id cr21sm3105812ejc.2.2021.05.07.02.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 02:53:41 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 8/8] trace-cmd: Add new function to set log level Date: Fri, 7 May 2021 12:53:33 +0300 Message-Id: <20210507095333.1080910-9-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210507095333.1080910-1-tz.stoyanov@gmail.com> References: <20210507095333.1080910-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Introduce a new trace-cmd internal function to set the application log level. trace_set_verbose() The log level can be set using string with log id or log name. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/include/trace-local.h | 2 ++ tracecmd/trace-cmd.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h index b3997d00..8da07c83 100644 --- a/tracecmd/include/trace-local.h +++ b/tracecmd/include/trace-local.h @@ -39,6 +39,8 @@ void usage(char **argv); extern int silence_warnings; extern int show_status; +int trace_set_verbose(char *level); + struct pid_record_data { int pid; int brass[2]; diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c index 60cd3ea1..4e4a73af 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -45,6 +45,47 @@ void *malloc_or_die(unsigned int size) return data; } +static struct trace_log_severity { + int id; + const char *name; +} log_severtity[] = { + { .id = TEP_LOG_NONE, .name = "none" }, + { .id = TEP_LOG_CRITICAL, .name = "crit" }, + { .id = TEP_LOG_ERROR, .name = "err" }, + { .id = TEP_LOG_WARNING, .name = "warn" }, + { .id = TEP_LOG_INFO, .name = "info" }, + { .id = TEP_LOG_DEBUG, .name = "debug" }, + { .id = TEP_LOG_ALL, .name = "all" }, +}; + +int trace_set_verbose(char *level) +{ + int id; + + if (!level) + return -1; + + if (isdigit(level[0])) { + id = atoi(level); + if (id >= TEP_LOG_NONE && id <= TEP_LOG_ALL) { + tracecmd_set_loglevel(id); + return 0; + } + } else { + int size = sizeof(log_severtity) / sizeof(log_severtity[0]); + int i; + + for (i = 0; i < size; i++) { + if (strlen(level) >= strlen(log_severtity[i].name) && + !strncmp(level, log_severtity[i].name, strlen(log_severtity[i].name))) { + tracecmd_set_loglevel(log_severtity[i].id); + return 0; + } + } + } + + return -1; +} /** * struct command