trace-cmd report: Add --cpus option
PATCH 1/1 trace-cmd report: Add --cpus option
From: "Steven Rostedt (Google)" <[email protected]>
Add the option --cpus to trace-cmd report to list the CPUs with data in the trace file and then exit.
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- .../trace-cmd/trace-cmd-report.1.txt | 3 ++ tracecmd/trace-read.c | 28 +++++++++++++++++++ tracecmd/trace-usage.c | 1 + 3 files changed, 32 insertions(+)
Documentation/trace-cmd/trace-cmd-report.1.txt +3 -0
@@ -251,6 +251,9 @@ OPTIONS Example: "--cpu 0,3" - show events from CPUs 0 and 3 "--cpu 2-4" - show events from CPUs 2, 3 and 4 +*--cpus*:: + List the CPUs that have data in the trace file then exit. + *--stat*:: If the trace.dat file recorded the final stats (outputed at the end of record) the *--stat* option can be used to retrieve them.
tracecmd/trace-read.c +28 -0
@@ -1542,6 +1542,7 @@ enum { OPT_kallsyms =253 , OPT_events =254 , OPT_cpu =255 , + OPT_cpus = 256, };void trace_report (int argc,char **argv)
@@ -1569,6 +1570,7 @@ void trace_report (int argc, char **argv)int show_uname =0 ;int show_version =0 ;int show_events =0 ; +int show_cpus =0 ;int print_events =0 ;int nanosec =0 ;int no_date =0 ;
@@ -1595,6 +1597,7 @@ void trace_report (int argc, char **argv)int option_index =0 ;static struct option long_options[] = { {"cpu" , required_argument,NULL , OPT_cpu}, + {"cpus" , no_argument,NULL , OPT_cpus}, {"events" , no_argument,NULL , OPT_events}, {"event" , required_argument,NULL , OPT_event}, {"filter-test" , no_argument,NULL ,'T' },
@@ -1724,6 +1727,9 @@ void trace_report (int argc, char **argv)case OPT_cpu:parse_cpulist (optarg);break ; +case OPT_cpus: + show_cpus =1 ; +break ;case OPT_events: print_events =1 ;break ;
@@ -1916,10 +1922,32 @@ void trace_report (int argc, char **argv)return ; } +if (show_cpus) { +int cpus; +int ret; +int i; + +if (!tracecmd_is_buffer_instance (handle)) { + ret =tracecmd_init_data (handle); +if (ret <0 ) +die ("failed to init data" ); + } + cpus =tracecmd_cpus (handle); +printf ("List of CPUs in %s with data:\n" , inputs->file); +for (i =0 ; i < cpus; i++) { +if (tracecmd_read_cpu_first (handle, i)) +printf (" %d\n" , i); + } +continue ; + } +set_event_flags (pevent, nohandler_events,TEP_EVENT_FL_NOHANDLE );set_event_flags (pevent, raw_events,TEP_EVENT_FL_PRINTRAW ); } +if (show_cpus) +return ; + otype =OUTPUT_NORMAL ;if (tracecmd_get_flags (handle) &TRACECMD_FL_RAW_TS ) {
tracecmd/trace-usage.c +1 -0
@@ -227,6 +227,7 @@ static struct usage_help usage_help[] = {" -O plugin option -O [plugin:]var[=val]\n" " --cpu <cpu1,cpu2,...> - filter events according to the given cpu list.\n" " A range of CPUs can be specified using 'cpuX-cpuY' notation.\n" +" --cpus - List the CPUs that have content in it then exit.\n" " --check-events return whether all event formats can be parsed\n" " --stat - show the buffer stats that were reported at the end of the record.\n" " --uname - show uname of the record, if it was saved\n"
Signature · 1 line
2.35.1