From patchwork Thu Dec 10 02:29:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963071 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B54F5C4361B for ; Thu, 10 Dec 2020 02:30:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DDC623C81 for ; Thu, 10 Dec 2020 02:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728557AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:39344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728564AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F98723D25 for ; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiA-00048L-Vj for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:42 -0500 Message-ID: <20201210022942.846080732@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:07 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 1/9] trace-cmd: Fix whitespace in usage message of trace-cmd report --ts-diff References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The "--ts-diff" description in "trace-cmd report -h" is not lined up with the other long options. Fix the whitespace so that it is. Link: https://lore.kernel.org/linux-trace-devel/20201201183655.723229785@goodmis.org Signed-off-by: Steven Rostedt (VMware) --- tracecmd/trace-usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 79610bd36bb7..5d73c5982984 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -228,7 +228,7 @@ static struct usage_help usage_help[] = { " to convert the displayed timestamps to seconds\n" " Affects the previous data file, unless there was no\n" " previous data file, in which case it becomes default\n" - " --ts-diff Show the delta timestamp between events.\n" + " --ts-diff Show the delta timestamp between events.\n" }, { "stream", From patchwork Thu Dec 10 02:29:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963073 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=-18.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 09EB1C4167B for ; Thu, 10 Dec 2020 02:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4C1523C81 for ; Thu, 10 Dec 2020 02:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:39350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3633523D39 for ; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-00048q-4a for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:43 -0500 Message-ID: <20201210022943.013917959@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:08 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/9] trace-cmd: Add reference to trace-cmd.org in README References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" This repo is mirrored in my personal github account, but that account is not mirrored, and there's been people submitting issues there. Add to the README, a reference to trace-cmd.org so that people will hopefully know the correct way to contribute. Link: https://lore.kernel.org/linux-trace-devel/20201201183655.868100504@goodmis.org Reported-by: David Runge (on IRC) Signed-off-by: Steven Rostedt (VMware) --- README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README b/README index fb06e754ee76..11531524e3bc 100644 --- a/README +++ b/README @@ -1,4 +1,7 @@ + + For more information on contributing please see: https://www.trace-cmd.org + Note: The official repositiory for trace-cmd and KernelShark is here: git://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git From patchwork Thu Dec 10 02:29:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963077 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 29A66C2BB40 for ; Thu, 10 Dec 2020 02:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E588B23D20 for ; Thu, 10 Dec 2020 02:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:39368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728580AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B7BD23D4E for ; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-00049L-B0 for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:43 -0500 Message-ID: <20201210022943.172449411@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:09 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 3/9] trace-cmd: Add --ts-check option to report References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Add a --ts-check option to trace-cmd report that will make sure that the timestamps do not go backwards, and will print out an error message if they do. Link: https://lore.kernel.org/linux-trace-devel/20201201183656.012642117@goodmis.org Signed-off-by: Steven Rostedt (VMware) --- Documentation/trace-cmd-report.1.txt | 4 ++++ tracecmd/trace-read.c | 29 +++++++++++++++++++++++++++- tracecmd/trace-usage.c | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/trace-cmd-report.1.txt b/Documentation/trace-cmd-report.1.txt index 864eb2d71f6a..de616cf4b47a 100644 --- a/Documentation/trace-cmd-report.1.txt +++ b/Documentation/trace-cmd-report.1.txt @@ -305,6 +305,10 @@ OPTIONS Show the time differences between events. The difference will appear in parenthesis just after the timestamp. +*--ts-check*:: + Make sure no timestamp goes backwards, and if it does, print out a warning + message of the fact. + EXAMPLES -------- diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index e18110745d37..0b3eb1bc1cd9 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -99,6 +99,7 @@ static int no_irqs; static int no_softirqs; static int tsdiff; +static int tscheck; static int latency_format; static bool raw_format; @@ -1192,6 +1193,7 @@ enum output_type { static void read_data_info(struct list_head *handle_list, enum output_type otype, int global) { + unsigned long long *last_timestamp; struct handle_list *handles; struct handle_list *last_handle; struct tep_record *record; @@ -1216,6 +1218,10 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype print_handle_file(handles); printf("cpus=%d\n", cpus); + last_timestamp = calloc(cpus, sizeof(*last_timestamp)); + if (!last_timestamp) + die("allocating timestamps"); + /* Latency trace is just all ASCII */ if (ret > 0) { if (multi_inputs) @@ -1286,6 +1292,8 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype list_for_each_entry(handles, handle_list, list) { record = get_next_record(handles); + if (!record) + continue; if (!last_record || (record && record->ts < last_record->ts)) { last_record = record; @@ -1293,12 +1301,26 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype } } if (last_record) { + int cpu = last_record->cpu; + if (cpu >= cpus) + die("cpu %d creater than %d\n", cpu, cpus); + if (tscheck && + last_timestamp[cpu] > last_record->ts) { + errno = 0; + warning("WARNING: Record on cpu %d went backwards: %lld to %lld delta: -%lld\n", + cpu, last_timestamp[cpu], + last_record->ts, + last_timestamp[cpu] - last_record->ts); + } + last_timestamp[cpu] = last_record->ts; print_handle_file(last_handle); trace_show_data(last_handle->handle, last_record); free_handle_record(last_handle); } } while (last_record); + free(last_timestamp); + if (profile) do_trace_profile(); @@ -1463,7 +1485,8 @@ static void add_hook(const char *arg) } enum { - OPT_version = 238, + OPT_version = 237, + OPT_tscheck = 238, OPT_tsdiff = 239, OPT_ts2secs = 240, OPT_tsoffset = 241, @@ -1550,6 +1573,7 @@ void trace_report (int argc, char **argv) {"ts-offset", required_argument, NULL, OPT_tsoffset}, {"ts2secs", required_argument, NULL, OPT_ts2secs}, {"ts-diff", no_argument, NULL, OPT_tsdiff}, + {"ts-check", no_argument, NULL, OPT_tscheck}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; @@ -1719,6 +1743,9 @@ void trace_report (int argc, char **argv) case OPT_tsdiff: tsdiff = 1; break; + case OPT_tscheck: + tscheck = 1; + break; default: usage(argv); } diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 5d73c5982984..0a338ed7d19c 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -229,6 +229,7 @@ static struct usage_help usage_help[] = { " Affects the previous data file, unless there was no\n" " previous data file, in which case it becomes default\n" " --ts-diff Show the delta timestamp between events.\n" + " --ts-check Check to make sure no time stamp on any CPU goes backwards.\n" }, { "stream", From patchwork Thu Dec 10 02:29:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963079 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 38106C1B0D9 for ; Thu, 10 Dec 2020 02:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12E0523C43 for ; Thu, 10 Dec 2020 02:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728580AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:39378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728584AbgLJCa0 (ORCPT ); Wed, 9 Dec 2020 21:30:26 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85E7123C44 for ; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-00049p-GH for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:43 -0500 Message-ID: <20201210022943.377786365@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:10 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 4/9] trace-cmd: Update .gitignore References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" The .gitignore file is somewhat out of date. Update the main file as well as adding a .gitignore in the tracecmd and kernel-shark directories. Remove the exec names that use to be included in the top level directory, and place them into the .gitignore in the directories that may build them. Ignore files caused by running "patch". Add *.data for perf files that may be in the directory. Add .pc and patches/ to ignore quilt directories. Add #*# to ignore emacs meta files. Add a .gitignore file in kernel-shark to include all the files that are built by the kernelshark build. Signed-off-by: Steven Rostedt (VMware) --- .gitignore | 10 ++++++---- kernel-shark/.gitignore | 22 ++++++++++++++++++++++ tracecmd/.gitignore | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 kernel-shark/.gitignore create mode 100644 tracecmd/.gitignore diff --git a/.gitignore b/.gitignore index 6759e51117a9..ca6c9cb68f6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,18 @@ *.o -trace-cmd *.so *.a *.dat +*.data *.patch .*.d +*.orig +*.rej +.pc *~ -kernelshark -trace-graph -trace-view *.pyc *.swp +\#*\# +patches/ tc_version.h ks_version.h ctracecmd_wrap.c diff --git a/kernel-shark/.gitignore b/kernel-shark/.gitignore new file mode 100644 index 000000000000..a752f4ed2706 --- /dev/null +++ b/kernel-shark/.gitignore @@ -0,0 +1,22 @@ +bin/cmd_split +bin/confio +bin/dfilter +bin/dhisto +bin/dload +bin/dplot +bin/kernelshark +bin/kshark-record +bin/widgetdemo +build/CMakeCache.txt +build/CMakeDoxyfile.in +build/CMakeDoxygenDefaults.cmake +build/CMakeFiles/ +build/Makefile +build/cmake_install.cmake +build/examples/ +build/src/ +kernelshark.desktop +lib/ +org.freedesktop.kshark-record.policy +src/KsCmakeDef.hpp + diff --git a/tracecmd/.gitignore b/tracecmd/.gitignore new file mode 100644 index 000000000000..30f93eb4ec2c --- /dev/null +++ b/tracecmd/.gitignore @@ -0,0 +1 @@ +trace-cmd From patchwork Thu Dec 10 02:29:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963083 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 8E75CC4167B for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61E2323C44 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728686AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgLJCbG (ORCPT ); Wed, 9 Dec 2020 21:31:06 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ADF1E23C82; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-0004AJ-LX; Wed, 09 Dec 2020 21:29:43 -0500 Message-ID: <20201210022943.538427964@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:11 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Tzvetomir (VMware) Stoyanov" Subject: [PATCH 5/9] libtracefs: Extend tracefs_iterate_raw_events() to iterate per CPU References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Tzvetomir (VMware) Stoyanov" There are some use cases where only raw events from particular CPUs should be iterated. An additional parameter is added to this API which allows only trace buffers for specified CPUs to be iterated. Link: https://lore.kernel.org/linux-trace-devel/20201204084739.555327-1-tz.stoyanov@gmail.com Signed-off-by: Tzvetomir (VMware) Stoyanov [ Ported to work with trace-cmd ] Signed-off-by: Steven Rostedt (VMware) --- include/tracefs/tracefs.h | 2 ++ lib/tracefs/tracefs-events.c | 6 ++++++ tracecmd/trace-record.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/tracefs/tracefs.h b/include/tracefs/tracefs.h index 3358e33d9f11..ce8b09ca5bd0 100644 --- a/include/tracefs/tracefs.h +++ b/include/tracefs/tracefs.h @@ -6,6 +6,7 @@ #ifndef _TRACE_FS_H #define _TRACE_FS_H +#include #include "traceevent/event-parse.h" char *tracefs_get_tracing_file(const char *name); @@ -44,6 +45,7 @@ char **tracefs_event_systems(const char *tracing_dir); char **tracefs_system_events(const char *tracing_dir, const char *system); int tracefs_iterate_raw_events(struct tep_handle *tep, struct tracefs_instance *instance, + cpu_set_t *cpus, int cpu_size, int (*callback)(struct tep_event *, struct tep_record *, int, void *), diff --git a/lib/tracefs/tracefs-events.c b/lib/tracefs/tracefs-events.c index a4e5215f8971..ba640a9e162c 100644 --- a/lib/tracefs/tracefs-events.c +++ b/lib/tracefs/tracefs-events.c @@ -116,6 +116,9 @@ get_events_in_page(struct tep_handle *tep, void *page, * per CPU trace buffers * @tep: a handle to the trace event parser context * @instance: ftrace instance, can be NULL for the top instance + * @cpus: Iterate only through the buffers of CPUs, set in the mask. + * If NULL, iterate through all CPUs. + * @cpu_size: size of @cpus set * @callback: A user function, called for each record from the file * @callback_context: A custom context, passed to the user callback function * @@ -126,6 +129,7 @@ get_events_in_page(struct tep_handle *tep, void *page, */ int tracefs_iterate_raw_events(struct tep_handle *tep, struct tracefs_instance *instance, + cpu_set_t *cpus, int cpu_size, int (*callback)(struct tep_event *, struct tep_record *, int, void *), @@ -166,6 +170,8 @@ int tracefs_iterate_raw_events(struct tep_handle *tep, if (strlen(name) < 4 || strncmp(name, "cpu", 3) != 0) continue; cpu = atoi(name + 3); + if (cpus && !CPU_ISSET_S(cpu, cpu_size, cpus)) + continue; sprintf(file, "%s/%s", path, name); ret = stat(file, &st); if (ret < 0 || !S_ISDIR(st.st_mode)) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 3a63f1bdda97..f8baed7dcd47 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -4585,7 +4585,7 @@ static unsigned long long find_time_stamp(struct tep_handle *tep) { unsigned long long ts = 0; - if (!tracefs_iterate_raw_events(tep, NULL, find_ts, &ts)) + if (!tracefs_iterate_raw_events(tep, NULL, NULL, 0, find_ts, &ts)) return ts; return 0; From patchwork Thu Dec 10 02:29:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963081 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=-10.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY 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 89A7CC4361B for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48F0823C43 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728689AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgLJCbG (ORCPT ); Wed, 9 Dec 2020 21:31:06 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA8C823D21; Thu, 10 Dec 2020 02:29:44 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-0004An-Ql; Wed, 09 Dec 2020 21:29:43 -0500 Message-ID: <20201210022943.700735522@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:12 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Tzvetomir (VMware) Stoyanov" Subject: [PATCH 6/9] libtracefs: Unit test for tracefs_iterate_raw_events() per CPU References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Tzvetomir (VMware) Stoyanov" The tracefs_iterate_raw_events() unit test is extended to verify per CPU iteration. Link: https://lore.kernel.org/linux-trace-devel/20201204084913.555490-1-tz.stoyanov@gmail.com Signed-off-by: Tzvetomir (VMware) Stoyanov Signed-off-by: Steven Rostedt (VMware) --- utest/tracefs-utest.c | 89 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index 78eda481190f..e7d637f523a7 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -18,25 +18,34 @@ #define TRACEFS_SUITE "trasefs library" #define TEST_INSTANCE_NAME "cunit_test_iter" -#define TEST_ARRAY_SIZE 50 +#define TEST_ARRAY_SIZE 500 static struct tracefs_instance *test_instance; static struct tep_handle *test_tep; -static int test_array[TEST_ARRAY_SIZE]; +struct test_sample { + int cpu; + int value; +}; +static struct test_sample test_array[TEST_ARRAY_SIZE]; static int test_found; static int test_callback(struct tep_event *event, struct tep_record *record, int cpu, void *context) { struct tep_format_field *field; - int val, i; + struct test_sample *sample; + int *cpu_test = (int *)context; + int i; + if (cpu_test && *cpu_test >= 0 && *cpu_test != cpu) + return 0; field = tep_find_field(event, "buf"); if (field) { - val = *((int *)(record->data + field->offset)); + sample = ((struct test_sample *)(record->data + field->offset)); for (i = 0; i < TEST_ARRAY_SIZE; i++) { - if (test_array[i] == val) { - test_array[i] = 0; + if (test_array[i].value == sample->value && + test_array[i].cpu == cpu) { + test_array[i].value = 0; test_found++; break; } @@ -48,43 +57,85 @@ static int test_callback(struct tep_event *event, struct tep_record *record, static void test_iter_write(void) { + int cpus = sysconf(_SC_NPROCESSORS_CONF); + cpu_set_t *cpuset, *cpusave; + int cpu_size; char *path; int i, fd; int ret; + cpuset = CPU_ALLOC(cpus); + cpusave = CPU_ALLOC(cpus); + cpu_size = CPU_ALLOC_SIZE(cpus); + CPU_ZERO_S(cpu_size, cpuset); + + sched_getaffinity(0, cpu_size, cpusave); path = tracefs_instance_get_file(test_instance, "trace_marker"); CU_TEST(path != NULL); fd = open(path, O_WRONLY); + tracefs_put_tracing_file(path); CU_TEST(fd >= 0); for (i = 0; i < TEST_ARRAY_SIZE; i++) { - test_array[i] = random(); - ret = write(fd, test_array + i, sizeof(int)); - CU_TEST(ret == sizeof(int)); + test_array[i].cpu = rand() % cpus; + test_array[i].value = random(); + if (!test_array[i].value) + test_array[i].value++; + CU_TEST(test_array[i].cpu < cpus); + CPU_ZERO_S(cpu_size, cpuset); + CPU_SET(test_array[i].cpu, cpuset); + sched_setaffinity(0, cpu_size, cpuset); + ret = write(fd, test_array + i, sizeof(struct test_sample)); + CU_TEST(ret == sizeof(struct test_sample)); } - tracefs_put_tracing_file(path); + sched_setaffinity(0, cpu_size, cpusave); close(fd); } +static void iter_raw_events_on_cpu(int cpu) +{ + int check = 0; + int ret; + int i; + + test_found = 0; + test_iter_write(); + ret = tracefs_iterate_raw_events(test_tep, test_instance, NULL, 0, + test_callback, &cpu); + CU_TEST(ret == 0); + if (cpu < 0) { + CU_TEST(test_found == TEST_ARRAY_SIZE); + } else { + for (i = 0; i < TEST_ARRAY_SIZE; i++) { + if (test_array[i].cpu == cpu) { + check++; + CU_TEST(test_array[i].value == 0) + } else { + CU_TEST(test_array[i].value != 0) + } + } + CU_TEST(test_found == check); + } +} + static void test_iter_raw_events(void) { + int cpus = sysconf(_SC_NPROCESSORS_CONF); int ret; + int i; - ret = tracefs_iterate_raw_events(NULL, test_instance, test_callback, NULL); + ret = tracefs_iterate_raw_events(NULL, test_instance, NULL, 0, test_callback, NULL); CU_TEST(ret < 0); - ret = tracefs_iterate_raw_events(test_tep, NULL, test_callback, NULL); + ret = tracefs_iterate_raw_events(test_tep, NULL, NULL, 0, test_callback, NULL); CU_TEST(ret == 0); - ret = tracefs_iterate_raw_events(test_tep, test_instance, NULL, NULL); + ret = tracefs_iterate_raw_events(test_tep, test_instance, NULL, 0, NULL, NULL); CU_TEST(ret < 0); - test_found = 0; - test_iter_write(); - ret = tracefs_iterate_raw_events(test_tep, test_instance, - test_callback, NULL); - CU_TEST(ret == 0); - CU_TEST(test_found == TEST_ARRAY_SIZE); + iter_raw_events_on_cpu(-1); + for (i = 0; i < cpus; i++) + iter_raw_events_on_cpu(i); } #define RAND_STR_SIZE 20 From patchwork Thu Dec 10 02:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963089 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=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E4611C2BB40 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B29A923C82 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728619AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1374823D22; Thu, 10 Dec 2020 02:29:45 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiB-0004BH-Vy; Wed, 09 Dec 2020 21:29:44 -0500 Message-ID: <20201210022943.863999811@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:13 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Tzvetomir Stoyanov (VMware)" Subject: [PATCH 7/9] trace-cmd: Use system trace libraries, if available References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Tzvetomir Stoyanov (VMware)" Check if libtraceevent and libtracefs are installed in the system and use them, otherwise build and use the local implementations. Link: https://lore.kernel.org/linux-trace-devel/20201126072707.906347-1-tz.stoyanov@gmail.com Signed-off-by: Tzvetomir Stoyanov (VMware) Signed-off-by: Steven Rostedt (VMware) --- Makefile | 40 ++++++++++++++++++++++++++++------------ lib/traceevent/Makefile | 2 ++ lib/tracefs/Makefile | 2 ++ tracecmd/Makefile | 6 ++++-- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8626b91bf653..c6cdeeaef46d 100644 --- a/Makefile +++ b/Makefile @@ -191,6 +191,8 @@ export prefix bindir src obj kshark-dir LIBS = -ldl + +LIBTRACEEVENT=libtraceevent LIBTRACEEVENT_DIR = $(obj)/lib/traceevent LIBTRACEEVENT_STATIC = $(LIBTRACEEVENT_DIR)/libtraceevent.a LIBTRACEEVENT_SHARED = $(LIBTRACEEVENT_DIR)/libtraceevent.so @@ -199,35 +201,48 @@ LIBTRACECMD_DIR = $(obj)/lib/trace-cmd LIBTRACECMD_STATIC = $(LIBTRACECMD_DIR)/libtracecmd.a LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so +LIBTRACEFS=libtracefs LIBTRACEFS_DIR = $(obj)/lib/tracefs LIBTRACEFS_STATIC = $(LIBTRACEFS_DIR)/libtracefs.a LIBTRACEFS_SHARED = $(LIBTRACEFS_DIR)/libtracefs.so -TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ - -L$(LIBTRACEEVENT_DIR) -ltraceevent \ - -L$(LIBTRACEFS_DIR) -ltracefs +ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEEVENT) > /dev/null 2>&1 && echo y"), y) +LIBTRACEEVENT_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEEVENT)") +LIBTRACEEVENT_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEEVENT)") +else +LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include +LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent +LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) +endif + +ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y"), y) +LIBTRACEFS_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEFS)") +LIBTRACEFS_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEFS)") +else +LIBTRACEFS_CFLAGS = -I$(src)/include/tracefs +LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs +LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) +endif + + +TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ + $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) export LIBS TRACE_LIBS export LIBTRACEEVENT_DIR LIBTRACECMD_DIR LIBTRACEFS_DIR export LIBTRACECMD_STATIC LIBTRACECMD_SHARED -export LIBTRACEEVENT_STATIC LIBTRACEEVENT_SHARED -export LIBTRACEFS_STATIC LIBTRACEFS_SHARED - export Q SILENT VERBOSE EXT # Include the utils include scripts/utils.mk INCLUDES = -I$(src)/include -I$(src)/../../include -INCLUDES += -I$(src)/include/traceevent INCLUDES += -I$(src)/include/trace-cmd -INCLUDES += -I$(src)/include/tracefs -INCLUDES += -I$(src)/lib/traceevent/include INCLUDES += -I$(src)/lib/trace-cmd/include INCLUDES += -I$(src)/lib/trace-cmd/include/private -INCLUDES += -I$(src)/lib/tracefs/include INCLUDES += -I$(src)/tracecmd/include -INCLUDES += -I$(obj)/tracecmd/include +INCLUDES += $(LIBTRACEEVENT_CFLAGS) +INCLUDES += $(LIBTRACEFS_CFLAGS) include $(src)/features.mk @@ -288,6 +303,7 @@ CMD_TARGETS = trace-cmd $(BUILD_PYTHON) # Default we just build trace-cmd # # If you want kernelshark, then do: make gui +# If you want all libraries, then do: make libs ### all: all_cmd plugins show_gui_make @@ -309,7 +325,7 @@ gui: force @echo "gui build complete" @echo " kernelshark located at $(kshark-dir)/bin" -trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) $(LIBTRACEFS_STATIC) \ +trace-cmd: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACECMD_STATIC) $(LIBTRACEFS_STATIC_BUILD) \ force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ diff --git a/lib/traceevent/Makefile b/lib/traceevent/Makefile index d0666911766d..c7f7cda07c91 100644 --- a/lib/traceevent/Makefile +++ b/lib/traceevent/Makefile @@ -6,6 +6,8 @@ bdir:=$(obj)/lib/traceevent DEFAULT_TARGET = $(bdir)/libtraceevent.a +CFLAGS += -I$(bdir)/include + OBJS = OBJS += event-parse.o OBJS += event-plugin.o diff --git a/lib/tracefs/Makefile b/lib/tracefs/Makefile index cbcce36288d9..895195172ffe 100644 --- a/lib/tracefs/Makefile +++ b/lib/tracefs/Makefile @@ -6,6 +6,8 @@ bdir:=$(obj)/lib/tracefs DEFAULT_TARGET = $(bdir)/libtracefs.a +CFLAGS += -I$(bdir)/include + OBJS = OBJS += tracefs-utils.o OBJS += tracefs-instance.o diff --git a/tracecmd/Makefile b/tracecmd/Makefile index 01f36c617eb4..de14176e2654 100644 --- a/tracecmd/Makefile +++ b/tracecmd/Makefile @@ -11,6 +11,8 @@ TARGETS = $(bdir)/trace-cmd $(TC_VERSION) BUILDGUI := 0 include $(src)/scripts/utils.mk +CFLAGS += -I$(bdir)/include + TRACE_CMD_OBJS = TRACE_CMD_OBJS += trace-cmd.o TRACE_CMD_OBJS += trace-record.o @@ -47,7 +49,7 @@ all_objs := $(sort $(ALL_OBJS)) all_deps := $(all_objs:$(bdir)/%.o=$(bdir)/.%.d) CONFIG_INCLUDES = -CONFIG_LIBS = -lrt -lpthread +CONFIG_LIBS = -lrt -lpthread $(TRACE_LIBS) CONFIG_FLAGS = all: $(TARGETS) @@ -67,7 +69,7 @@ $(all_objs): | $(bdir) $(bdir)/trace-cmd: $(ALL_OBJS) $(Q)$(do_app_build) -$(bdir)/trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC) $(LIBTRACEFS_STATIC) +$(bdir)/trace-cmd: $(LIBTRACECMD_STATIC) $(bdir)/%.o: %.c $(Q)$(call do_compile) From patchwork Thu Dec 10 02:29:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963085 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C2717C433FE for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91D3A23C43 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728619AbgLJCbG (ORCPT ); Wed, 9 Dec 2020 21:31:06 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B23E23D4F for ; Thu, 10 Dec 2020 02:29:45 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiC-0004Bl-4v for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:44 -0500 Message-ID: <20201210022944.023068632@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:14 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 8/9] trace-cmd: Have "make test" use system libraries if present References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" Update the Makefiles so that "make test" will use the system libraries of libtraceevent and libtracefs if they are present, and only build them locally if they are not. Signed-off-by: Steven Rostedt (VMware) --- Makefile | 5 ++++- utest/Makefile | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c6cdeeaef46d..8d82db567a52 100644 --- a/Makefile +++ b/Makefile @@ -215,6 +215,8 @@ LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) endif +export LIBTRACEEVENT_CFLAGS LIBTRACEEVENT_LDLAGS + ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y"), y) LIBTRACEFS_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEFS)") LIBTRACEFS_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEFS)") @@ -224,6 +226,7 @@ LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) endif +export LIBTRACEFS_CFLAGS LIBTRACEFS_LDLAGS TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) @@ -358,7 +361,7 @@ libtracefs.so: $(LIBTRACEFS_SHARED) libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) $(LIBTRACEFS_SHARED) -test: force $(LIBTRACEEVENT_STATIC) $(LIBTRACEFS_STATIC) $(LIBTRACECMD_STATIC) +test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC) ifneq ($(CUNIT_INSTALLED),1) $(error CUnit framework not installed, cannot build unit tests)) endif diff --git a/utest/Makefile b/utest/Makefile index d635650d46e1..55828abb59e3 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -9,9 +9,7 @@ OBJS = OBJS += trace-utest.o OBJS += tracefs-utest.o -LIBS += -lcunit \ - -L$(LIBTRACEFS_DIR) -ltracefs \ - -L$(LIBTRACEEVENT_DIR) -ltraceevent +LIBS += -lcunit $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) OBJS := $(OBJS:%.o=$(bdir)/%.o) DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) From patchwork Thu Dec 10 02:29:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11963087 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A2F17C19425 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A97723C81 for ; Thu, 10 Dec 2020 02:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728489AbgLJCbH (ORCPT ); Wed, 9 Dec 2020 21:31:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728620AbgLJCbG (ORCPT ); Wed, 9 Dec 2020 21:31:06 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59EAF23D50 for ; Thu, 10 Dec 2020 02:29:45 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1knBiC-0004CF-Am for linux-trace-devel@vger.kernel.org; Wed, 09 Dec 2020 21:29:44 -0500 Message-ID: <20201210022944.212527059@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 09 Dec 2020 21:29:15 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 9/9] trace-cmd: Only install libtraceevent and libtracefs if not in system References: <20201210022906.112066412@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" If libtraceevent and libtracefs are not built locally, because they are already on the local system, do not install them either. Signed-off-by: Steven Rostedt (VMware) --- Makefile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8d82db567a52..022b7c3d89d4 100644 --- a/Makefile +++ b/Makefile @@ -213,6 +213,7 @@ else LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) +INSTALL_TRACEEVENT = install_traceevent endif export LIBTRACEEVENT_CFLAGS LIBTRACEEVENT_LDLAGS @@ -224,6 +225,7 @@ else LIBTRACEFS_CFLAGS = -I$(src)/include/tracefs LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) +INSTALL_TRACEFS = install_tracefs endif export LIBTRACEFS_CFLAGS LIBTRACEFS_LDLAGS @@ -343,7 +345,7 @@ $(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/trace_python_dir \ $(LIBTRACECMD_STATIC): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ -$(LIBTRACECMD_SHARED): force $(LIBTRACEEVENT_SHARED) +$(LIBTRACECMD_SHARED): force $(LIBTRACEEVENT_SHARED_BUILD) $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ $(LIBTRACEFS_STATIC): force @@ -359,7 +361,7 @@ libtracecmd.so: $(LIBTRACECMD_SHARED) libtracefs.a: $(LIBTRACEFS_STATIC) libtracefs.so: $(LIBTRACEFS_SHARED) -libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) $(LIBTRACEFS_SHARED) +libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED_BUILD) $(LIBTRACEFS_SHARED_BUILD) test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC) ifneq ($(CUNIT_INSTALLED),1) @@ -432,18 +434,22 @@ install: install_cmd install_gui: install_cmd gui $(Q)$(MAKE) $(S) -C $(kshark-dir)/build install -install_libs: libs - $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)/trace-cmd) +install_traceevent: $(LIBTRACEEVENT_STATIC_BUILD) $(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ)/traceevent) - $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs) $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ)/traceevent) $(Q)$(call do_install,$(src)/include/traceevent/trace-seq.h,$(includedir_SQ)/traceevent) - $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd) - $(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs) - $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd) $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/traceevent) + +install_tracefs: $(LIBTRACEFS_STATIC_BUILD) + $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs) + $(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs) $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/tracefs) +install_libs: libs $(INSTALL_TRACEEVENT) $(INSTALL_TRACEFS) + $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)/trace-cmd) + $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd) + $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd) + doc: $(MAKE) -C $(src)/Documentation all doc_gui: