From patchwork Fri Dec 29 03:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13506312 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82A1317D1 for ; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DFEBC433C8; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rJ3Ou-00000000I4b-2CUL; Thu, 28 Dec 2023 22:19:08 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 1/4] trace-cmd show: Re-arrange the enum long option values Date: Thu, 28 Dec 2023 22:16:44 -0500 Message-ID: <20231229031907.69432-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231229031907.69432-1-rostedt@goodmis.org> References: <20231229031907.69432-1-rostedt@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" To simplify adding enums to trace-cmd show, re-arrange the enum values. They can be larger than 255 as well. No functional changes. Signed-off-by: Steven Rostedt (Google) --- tracecmd/trace-show.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tracecmd/trace-show.c b/tracecmd/trace-show.c index eb3285277fe1..796c587c0cd0 100644 --- a/tracecmd/trace-show.c +++ b/tracecmd/trace-show.c @@ -11,16 +11,16 @@ #include "trace-local.h" enum { - OPT_tracing_on = 255, - OPT_current_tracer = 254, - OPT_buffer_size_kb = 253, - OPT_buffer_total_size_kb = 252, - OPT_ftrace_filter = 251, - OPT_ftrace_notrace = 250, - OPT_ftrace_pid = 249, - OPT_graph_function = 248, - OPT_graph_notrace = 247, - OPT_cpumask = 246, + OPT_cpumask = 240, + OPT_graph_notrace, + OPT_graph_function, + OPT_ftrace_pid, + OPT_ftrace_notrace, + OPT_ftrace_filter, + OPT_buffer_total_size_kb, + OPT_buffer_size_kb, + OPT_current_tracer, + OPT_tracing_on, }; void trace_show(int argc, char **argv) From patchwork Fri Dec 29 03:16:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13506314 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94CC11857 for ; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29B7BC433C9; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rJ3Ou-00000000I4e-2JRT; Thu, 28 Dec 2023 22:19:08 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 2/4] trace-cmd show: Add --buffer-subbuf-size option Date: Thu, 28 Dec 2023 22:16:45 -0500 Message-ID: <20231229031907.69432-3-rostedt@goodmis.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231229031907.69432-1-rostedt@goodmis.org> References: <20231229031907.69432-1-rostedt@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" Add an option to trace-cmd show that displays the subbuffer size in kilobytes. Signed-off-by: Steven Rostedt (Google) --- Documentation/trace-cmd/trace-cmd-show.1.txt | 5 +++++ tracecmd/trace-show.c | 6 ++++++ tracecmd/trace-usage.c | 1 + 3 files changed, 12 insertions(+) diff --git a/Documentation/trace-cmd/trace-cmd-show.1.txt b/Documentation/trace-cmd/trace-cmd-show.1.txt index ea2fda285e18..ac40dacf7061 100644 --- a/Documentation/trace-cmd/trace-cmd-show.1.txt +++ b/Documentation/trace-cmd/trace-cmd-show.1.txt @@ -60,6 +60,11 @@ OPTIONS *--buffer_total_size*:: Show the total size of all buffers. +*--buffer_subbuf_size*:: + Show the size in kilobytes of the sub-buffers of the ring buffer. + The ring buffer is broken up into equal size sub-buffers were an event can only + be as big as the sub-buffer data section (the size minus its meta data). + *--ftrace_filter*:: Show what function filters are set. diff --git a/tracecmd/trace-show.c b/tracecmd/trace-show.c index 796c587c0cd0..17eb098952f7 100644 --- a/tracecmd/trace-show.c +++ b/tracecmd/trace-show.c @@ -17,6 +17,7 @@ enum { OPT_ftrace_pid, OPT_ftrace_notrace, OPT_ftrace_filter, + OPT_buffer_subbuf_size_kb, OPT_buffer_total_size_kb, OPT_buffer_size_kb, OPT_current_tracer, @@ -42,6 +43,7 @@ void trace_show(int argc, char **argv) {"current_tracer", no_argument, NULL, OPT_current_tracer}, {"buffer_size", no_argument, NULL, OPT_buffer_size_kb}, {"buffer_total_size", no_argument, NULL, OPT_buffer_total_size_kb}, + {"buffer_subbuf_size", no_argument, NULL, OPT_buffer_subbuf_size_kb}, {"ftrace_filter", no_argument, NULL, OPT_ftrace_filter}, {"ftrace_notrace", no_argument, NULL, OPT_ftrace_notrace}, {"ftrace_pid", no_argument, NULL, OPT_ftrace_pid}, @@ -102,6 +104,10 @@ void trace_show(int argc, char **argv) show_instance_file(instance, "buffer_total_size_kb"); stop = 1; break; + case OPT_buffer_subbuf_size_kb: + show_instance_file(instance, "buffer_subbuf_size_kb"); + stop = 1; + break; case OPT_ftrace_filter: show_instance_file(instance, "set_ftrace_filter"); stop = 1; diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 37d576b009ac..7dc9b1871398 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -180,6 +180,7 @@ static struct usage_help usage_help[] = { " --current_tracer\n" " --buffer_size (for buffer_size_kb)\n" " --buffer_total_size (for buffer_total_size_kb)\n" + " --buffer_subbuf_size (for buffer_subbuf_size_kb)\n" " --ftrace_filter (for set_ftrace_filter)\n" " --ftrace_notrace (for set_ftrace_notrace)\n" " --ftrace_pid (for set_ftrace_pid)\n" From patchwork Fri Dec 29 03:16:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13506311 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5967517D1 for ; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26A4AC433CA; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rJ3Ou-00000000I4j-2R42; Thu, 28 Dec 2023 22:19:08 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 3/4] trace-cmd show: Add option to read buffer_percent Date: Thu, 28 Dec 2023 22:16:46 -0500 Message-ID: <20231229031907.69432-4-rostedt@goodmis.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231229031907.69432-1-rostedt@goodmis.org> References: <20231229031907.69432-1-rostedt@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" Add trace-cmd show --buffer_percent to show the value of the buffer_percent file. Signed-off-by: Steven Rostedt (Google) --- Documentation/trace-cmd/trace-cmd-show.1.txt | 8 ++++++++ tracecmd/trace-show.c | 6 ++++++ tracecmd/trace-usage.c | 1 + 3 files changed, 15 insertions(+) diff --git a/Documentation/trace-cmd/trace-cmd-show.1.txt b/Documentation/trace-cmd/trace-cmd-show.1.txt index ac40dacf7061..f85c070b0598 100644 --- a/Documentation/trace-cmd/trace-cmd-show.1.txt +++ b/Documentation/trace-cmd/trace-cmd-show.1.txt @@ -65,6 +65,14 @@ OPTIONS The ring buffer is broken up into equal size sub-buffers were an event can only be as big as the sub-buffer data section (the size minus its meta data). +*--buffer_percent*:: + Show the percentage the buffer must be filled before a reader that is blocked + on the trace_pipe_raw file will be woken up. + + 0 : wake up immediately on any new data + 1 - 99 : wake up on this percentage of the sub-buffers being full + 100 : wake up after the buffer is full and the writer is on the last sub-buffer + *--ftrace_filter*:: Show what function filters are set. diff --git a/tracecmd/trace-show.c b/tracecmd/trace-show.c index 17eb098952f7..d91362e47c50 100644 --- a/tracecmd/trace-show.c +++ b/tracecmd/trace-show.c @@ -20,6 +20,7 @@ enum { OPT_buffer_subbuf_size_kb, OPT_buffer_total_size_kb, OPT_buffer_size_kb, + OPT_buffer_percent, OPT_current_tracer, OPT_tracing_on, }; @@ -44,6 +45,7 @@ void trace_show(int argc, char **argv) {"buffer_size", no_argument, NULL, OPT_buffer_size_kb}, {"buffer_total_size", no_argument, NULL, OPT_buffer_total_size_kb}, {"buffer_subbuf_size", no_argument, NULL, OPT_buffer_subbuf_size_kb}, + {"buffer_percent", no_argument, NULL, OPT_buffer_percent}, {"ftrace_filter", no_argument, NULL, OPT_ftrace_filter}, {"ftrace_notrace", no_argument, NULL, OPT_ftrace_notrace}, {"ftrace_pid", no_argument, NULL, OPT_ftrace_pid}, @@ -108,6 +110,10 @@ void trace_show(int argc, char **argv) show_instance_file(instance, "buffer_subbuf_size_kb"); stop = 1; break; + case OPT_buffer_percent: + show_instance_file(instance, "buffer_percent"); + stop = 1; + break; case OPT_ftrace_filter: show_instance_file(instance, "set_ftrace_filter"); stop = 1; diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 7dc9b1871398..3e5456d27e3d 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -181,6 +181,7 @@ static struct usage_help usage_help[] = { " --buffer_size (for buffer_size_kb)\n" " --buffer_total_size (for buffer_total_size_kb)\n" " --buffer_subbuf_size (for buffer_subbuf_size_kb)\n" + " --buffer_percent (for buffer_percent)\n" " --ftrace_filter (for set_ftrace_filter)\n" " --ftrace_notrace (for set_ftrace_notrace)\n" " --ftrace_pid (for set_ftrace_pid)\n" From patchwork Fri Dec 29 03:16:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13506315 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 961651C26 for ; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E402C433CB; Fri, 29 Dec 2023 03:18:18 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rJ3Ou-00000000I4n-2Y1s; Thu, 28 Dec 2023 22:19:08 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" Subject: [PATCH 4/4] trace-cmd stat: Use tracefs_instance_file_read() Date: Thu, 28 Dec 2023 22:16:47 -0500 Message-ID: <20231229031907.69432-5-rostedt@goodmis.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231229031907.69432-1-rostedt@goodmis.org> References: <20231229031907.69432-1-rostedt@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Steven Rostedt (Google)" Instead of open coding reading an instance file, use the libtracefs library tracefs_instance_file_read(). Signed-off-by: Steven Rostedt (Google) --- tracecmd/trace-stat.c | 45 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c index 391a05ffcec9..9a6e22254b48 100644 --- a/tracecmd/trace-stat.c +++ b/tracecmd/trace-stat.c @@ -24,19 +24,6 @@ static inline int is_top_instance(struct buffer_instance *instance) return instance == &top_instance; } -static int get_instance_file_fd(struct buffer_instance *instance, - const char *file) -{ - char *path; - int fd; - - path = tracefs_instance_get_file(instance->tracefs, file); - fd = open(path, O_RDONLY); - tracefs_put_tracing_file(path); - - return fd; -} - char *strstrip(char *str) { char *s; @@ -108,22 +95,6 @@ char *get_file_content(const char *file) return str; } -static char *get_instance_file_content(struct buffer_instance *instance, - const char *file) -{ - char *str = NULL; - int fd; - - fd = get_instance_file_fd(instance, file); - if (fd < 0) - return NULL; - - str = get_fd_content(fd, file); - - close(fd); - return str; -} - static void report_file(struct buffer_instance *instance, char *name, char *def_value, char *description) { @@ -132,7 +103,7 @@ static void report_file(struct buffer_instance *instance, if (!tracefs_file_exists(instance->tracefs, name)) return; - str = get_instance_file_content(instance, name); + str = tracefs_instance_file_read(instance->tracefs, name, NULL); if (!str) return; cont = strstrip(str); @@ -346,7 +317,7 @@ static void report_events(struct buffer_instance *instance) enum event_process processed = PROCESSED_NONE; enum event_process processed_part = PROCESSED_NONE; - str = get_instance_file_content(instance, "events/enable"); + str = tracefs_instance_file_read(instance->tracefs, "events/enable", NULL); if (!str) return; @@ -664,7 +635,7 @@ static void report_buffers(struct buffer_instance *instance) char file[FILE_SIZE]; int cpu; - str = get_instance_file_content(instance, "buffer_size_kb"); + str = tracefs_instance_file_read(instance->tracefs, "buffer_size_kb", NULL); if (!str) return; @@ -684,7 +655,7 @@ static void report_buffers(struct buffer_instance *instance) for (cpu = 0; ; cpu++) { snprintf(file, FILE_SIZE, "per_cpu/cpu%d/buffer_size_kb", cpu); - str = get_instance_file_content(instance, file); + str = tracefs_instance_file_read(instance->tracefs, file, NULL); if (!str) break; @@ -699,7 +670,7 @@ static void report_buffers(struct buffer_instance *instance) total: free(str); - str = get_instance_file_content(instance, "buffer_total_size_kb"); + str = tracefs_instance_file_read(instance->tracefs, "buffer_total_size_kb", NULL); if (!str) return; @@ -733,7 +704,7 @@ static void report_cpumask(struct buffer_instance *instance) int n; int i; - str = get_instance_file_content(instance, "tracing_cpumask"); + str = tracefs_instance_file_read(instance->tracefs, "tracing_cpumask", NULL); if (!str) return; @@ -783,7 +754,7 @@ static void report_probes(struct buffer_instance *instance, int newline; int i; - str = get_instance_file_content(instance, file); + str = tracefs_instance_file_read(instance->tracefs, file, NULL); if (!str) return; @@ -828,7 +799,7 @@ static void report_traceon(struct buffer_instance *instance) char *str; char *cont; - str = get_instance_file_content(instance, "tracing_on"); + str = tracefs_instance_file_read(instance->tracefs, "tracing_on", NULL); if (!str) return;