trace-cmd: Various updates
cover trace-cmd: Various updates
From: "Steven Rostedt (Google)" <[email protected]>
Various trace-cmd updates:
- Add a way to show "max_latency"
- Use tracefs_instances() helper function
- Use tracefs_filter_functions() helper function
Steven Rostedt (VMware) (4):
trace-cmd list: Use tracefs_filter_functions() trace-cmd show: Add --max_latency
trace-cmd list: Use tracefs_instances() to list instances trace-cmd stat: Use tracefs_instances() instead of walking them
tracecmd/trace-list.c | 54 ++++++++++++++++-------------------------- tracecmd/trace-show.c | 6 +++++ tracecmd/trace-stat.c | 26 ++++++++++---------- tracecmd/trace-usage.c | 1 + 4 files changed, 41 insertions(+), 46 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/4 trace-cmd list: Use tracefs_filter_functions()
From: "Steven Rostedt (VMware)" <[email protected]>
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.
--- tracecmd/trace-list.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
tracecmd/trace-list.c +12 -13
@@ -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); }
Signature · 1 line
2.45.2
PATCH 2/4 trace-cmd show: Add --max_latency
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Add the --max_latency option to trace-cmd show to display the contents of tracing_max_latency.
--- tracecmd/trace-show.c | 6 ++++++ tracecmd/trace-usage.c | 1 + 2 files changed, 7 insertions(+)
tracecmd/trace-show.c +6 -0
@@ -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); }
tracecmd/trace-usage.c +1 -0
@@ -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",
Signature · 1 line
2.45.2
PATCH 3/4 trace-cmd list: Use tracefs_instances() to list instances
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Instead of walking the instances directory, use the tracefs_instances() function to find all the instances.
--- tracecmd/trace-list.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
tracecmd/trace-list.c +9 -20
@@ -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); }
Signature · 1 line
2.45.2
PATCH 4/4 trace-cmd stat: Use tracefs_instances() instead of walking them
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
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.
--- tracecmd/trace-stat.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
tracecmd/trace-stat.c +13 -13
@@ -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)
Signature · 1 line
2.45.2