From patchwork Fri Oct 11 18:26:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13832893 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 3CB5038DF9 for ; Fri, 11 Oct 2024 18:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; cv=none; b=LKfZHh7w+vRIqIpm9oMS2Z2mYsU5/x0eNtoBkv2qWRae34lYwhLQCw8pSmnwDbz9vsDXbn0RxRd6S7cODNe6MFUI2FjVuXLTs+25HmhCZRXwB3VFw8CTXqfDbXJRyz0osaZuVlGtw/jYGY+c8dA8WW7j05qgyQRjbcN4B0emdic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; c=relaxed/simple; bh=PBVuWp2josTlAriSnjIzdw4bSD/9qVgzDDV6iDPnfnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtD7P1zYbLLqLChS+iyLW/XqC3d6f4DfPI2cf8e0339l4jIFAZyJ2TxA5icIbHu/m7/Qr3nlf0Czze6mmdC4FvDjmxqp9pG9bzL3WRc7goHasNC8yMnSVwGkJZd7eLS9vMf4yoJl/GKiH2OPJ0GtqX/mgs5HNwpkX5mdtraj4qM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5ACFC4CEC3; Fri, 11 Oct 2024 18:27:43 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1szKMk-00000001V1C-2EQX; Fri, 11 Oct 2024 14:27:54 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (VMware)" Subject: [PATCH 1/4] trace-cmd list: Use tracefs_filter_functions() Date: Fri, 11 Oct 2024 14:26:51 -0400 Message-ID: <20241011182752.357499-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011182752.357499-1-rostedt@goodmis.org> References: <20241011182752.357499-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 (VMware)" Instead of reading the available_filter_functions file and parsing it manually, simply call tarcefs_filter_functions() and report what it wrote as it does the work for us. Signed-off-by: Steven Rostedt (VMware) --- tracecmd/trace-list.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c index fbf2882e1a83..0fbb8eabd44b 100644 --- a/tracecmd/trace-list.c +++ b/tracecmd/trace-list.c @@ -236,16 +236,6 @@ static void process_events(process_file_func func, const char *re, int flags) regfree(&event_reg); } -static int show_file_write(char *buf, int len, int flags) -{ - return fwrite(buf, 1, len, stdout); -} - -static void show_file_re(const char *name, const char *re) -{ - process_file_re(show_file_write, name, re, 0); -} - static char *get_event_file(const char *type, char *buf, int len) { char *system; @@ -476,10 +466,19 @@ static void show_clocks(void) static void show_functions(const char *funcre) { - if (funcre) - show_file_re("available_filter_functions", funcre); - else + char **list; + int i; + + if (!funcre) { show_file("available_filter_functions"); + return; + } + + if (tracefs_filter_functions(funcre, NULL, &list) < 0) + die("Failed to read filte functions"); + for (i = 0; list[i]; i++) + printf("%s\n", list[i]); + tracefs_list_free(list); } From patchwork Fri Oct 11 18:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13832891 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 3CBBC1C689D for ; Fri, 11 Oct 2024 18:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; cv=none; b=d8YOBXYgbyf9Lb5N6RfjtYePzTHxaBRRYkKL8wRxQOr6GzbIRSIDaY4FMQ3O7r5rOUx5wX9VkGc941AMrvcFfQ85A2HUitJ21uxJm1h00jPlxITuiNPWeHONBp13O6TWWrZkIXS2aAFz2SOfRgK6zLUKg3nXNPiPXOqne4RvQVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; c=relaxed/simple; bh=GinRNeJAB4dhB2YP61/7STN3CuM1gHgGnhlhc7klMCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S2t5N6luKqGYHzezzKDy7i3GnIFFZN5sRDGlp/lVh+3TUJwf00ekzfJRLnZCxrBAopVWYJ9hXc7gf+5qO7AvbffaP0mgUogH+DSQlE/oAI25PmLKva7/Yfv7QVlGgxdSq4K8KS45D93vVXczsZ/D4nMboxPgTmEXKhgNOxNNHL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF7CEC4CECE; Fri, 11 Oct 2024 18:27:43 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1szKMk-00000001V1F-2Mix; Fri, 11 Oct 2024 14:27:54 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (VMware)" Subject: [PATCH 2/4] trace-cmd show: Add --max_latency Date: Fri, 11 Oct 2024 14:26:52 -0400 Message-ID: <20241011182752.357499-3-rostedt@goodmis.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011182752.357499-1-rostedt@goodmis.org> References: <20241011182752.357499-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 (VMware)" Add the --max_latency option to trace-cmd show to display the contents of tracing_max_latency. Signed-off-by: Steven Rostedt (VMware) --- tracecmd/trace-show.c | 6 ++++++ tracecmd/trace-usage.c | 1 + 2 files changed, 7 insertions(+) diff --git a/tracecmd/trace-show.c b/tracecmd/trace-show.c index cf70d86ca61c..c92c87990a23 100644 --- a/tracecmd/trace-show.c +++ b/tracecmd/trace-show.c @@ -25,6 +25,7 @@ enum { OPT_tracing_on, OPT_hist, OPT_trigger, + OPT_max_latency, }; void trace_show(int argc, char **argv) @@ -58,6 +59,7 @@ void trace_show(int argc, char **argv) {"graph_function", no_argument, NULL, OPT_graph_function}, {"graph_notrace", no_argument, NULL, OPT_graph_notrace}, {"cpumask", no_argument, NULL, OPT_cpumask}, + {"max_latency", no_argument, NULL, OPT_max_latency}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; @@ -151,6 +153,10 @@ void trace_show(int argc, char **argv) show_instance_file(instance, "tracing_cpumask"); stop = 1; break; + case OPT_max_latency: + show_instance_file(instance, "tracing_max_latency"); + stop = 1; + break; default: usage(argv); } diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 8bbf2e3e79d6..7139016e5274 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -189,6 +189,7 @@ static struct usage_help usage_help[] = { " --graph_function (for set_graph_function)\n" " --graph_notrace (for set_graph_notrace)\n" " --cpumask (for tracing_cpumask)\n" + " --max_latency (for tracing_max_latency)\n" }, { "reset", From patchwork Fri Oct 11 18:26:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13832892 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 3CC121C68AC for ; Fri, 11 Oct 2024 18:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; cv=none; b=HtX+jxHq8Pjp4dEkPFCizhWYtbF/ndu89PPCwPkW+sA0DNVu2HTYLC49I1UbWMIbkKAdaDJuWo8wmEh4hXKj9NL5a+1fEZwu6HDp6wIF2QlZoGLTaGiBLj0V+p1WHYmhifC2eFFnGrarmX3k0WJsupCKUiFekVLQNh9EybLnWvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; c=relaxed/simple; bh=AmA4nJjKpsd7bjZPoe5wu4DjQwibukGbL+POWmAwT38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XpOMTB34LF0a76sfBPcGMuaMkJK1/RMl5rgA0iTdyqMuWTd5IOoFxbvBTA3kSzeWWD/8vsb/kBOmJybwnNXjOVPwOn6Cdj4TT/fh4yodDzBIDjT9QGjEQ3yDtwPwH8Jm3/qz04c/T7cHGwJwSKTVkDtTIAjb40aHSXGH6d8Epm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED24BC4CEC7; Fri, 11 Oct 2024 18:27:43 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1szKMk-00000001V1J-2T4M; Fri, 11 Oct 2024 14:27:54 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (VMware)" Subject: [PATCH 3/4] trace-cmd list: Use tracefs_instances() to list instances Date: Fri, 11 Oct 2024 14:26:53 -0400 Message-ID: <20241011182752.357499-4-rostedt@goodmis.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011182752.357499-1-rostedt@goodmis.org> References: <20241011182752.357499-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 (VMware)" Instead of walking the instances directory, use the tracefs_instances() function to find all the instances. Signed-off-by: Steven Rostedt (VMware) --- tracecmd/trace-list.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c index 0fbb8eabd44b..8badd1f2e3e3 100644 --- a/tracecmd/trace-list.c +++ b/tracecmd/trace-list.c @@ -484,31 +484,20 @@ static void show_functions(const char *funcre) static void show_buffers(void) { - struct dirent *dent; - DIR *dir; - char *path; - int printed = 0; + char **list; + int i; - path = tracefs_get_tracing_file("instances"); - dir = opendir(path); - tracefs_put_tracing_file(path); - if (!dir) + list = tracefs_instances(NULL); + if (!list) die("Can not read instance directory"); - while ((dent = readdir(dir))) { - const char *name = dent->d_name; - - if (strcmp(name, ".") == 0 || - strcmp(name, "..") == 0) - continue; - - printf("%s\n", name); - printed = 1; - } - closedir(dir); + for (i = 0; list[i]; i++) + printf("%s\n", list[i]); - if (!printed) + if (!i) printf("No buffer instances defined\n"); + + tracefs_list_free(list); } From patchwork Fri Oct 11 18:26:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13832894 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 3CC5F1C68BF for ; Fri, 11 Oct 2024 18:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; cv=none; b=DnecfIBxA1Z0ngb62Qs6y8rwzGORLJ0C1WC5N87PjNA42cE5SklwvyflpJNJND85FvhkgnWNPvna9kizw2r10HkbOdhnvGuWCv2Flw8yoNNNEEIlzsq6x3wlf9451vni2zp5Lr799FyH/YeJ4NnfWjLn8KkStzD6+jj7JPTrYj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728671264; c=relaxed/simple; bh=9fGvKar5twjECkK+6RsSjh+1jfdjInvrNC8nZJern+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WCMXh589vIja5j53ioR2Cg9VBgxGSlxsqap5SmYlIihYEs0w/DEH7ervLR5+RWaiYVU680gITNGDcPMmM5cSkr1MLOpLgw9d9VJ6k1TJkczmzOHJJ1yylpmXKS+icQavATn06QZ1u/8/B5NYNw7w06PiaUauyMMR4P2BNNkKCvY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E466C4CED2; Fri, 11 Oct 2024 18:27:44 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1szKMk-00000001V1N-2a6N; Fri, 11 Oct 2024 14:27:54 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (VMware)" Subject: [PATCH 4/4] trace-cmd stat: Use tracefs_instances() instead of walking them Date: Fri, 11 Oct 2024 14:26:54 -0400 Message-ID: <20241011182752.357499-5-rostedt@goodmis.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241011182752.357499-1-rostedt@goodmis.org> References: <20241011182752.357499-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 (VMware)" Use the new tracefs_instances() function to retrieve a list of instances on the system instead of calling tracefs_instance_walk() and having a helper function do the printing. This simplifies the code a bit. Signed-off-by: Steven Rostedt (VMware) --- tracecmd/trace-stat.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c index 1d95d9934b47..7ac62f2a3076 100644 --- a/tracecmd/trace-stat.c +++ b/tracecmd/trace-stat.c @@ -113,23 +113,23 @@ static void report_file(struct buffer_instance *instance, free(str); } -static int report_instance(const char *name, void *data) +static void report_instances(void) { - bool *first = (bool *)data; + char **list; + int i; - if (*first) { - *first = false; - printf("\nInstances:\n"); - } - printf(" %s\n", name); - return 0; -} + list = tracefs_instances(NULL); -static void report_instances(void) -{ - bool first = true; + if (!list || !list[0]) + goto out; + + printf("\nInstances:\n"); - tracefs_instances_walk(report_instance, &first); + for (i = 0; list[i]; i++) + printf(" %s\n", list[i]); + + out: + tracefs_list_free(list); } struct event_iter *trace_event_iter_alloc(const char *path)