diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-03-14 13:09:55 -0400 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-03-15 12:14:04 -0400 |
commit | 0182ed722e6ae96d471caa546039202fb12cb36f (patch) | |
tree | cc9cd9d2fe5f6db9ed4d5e32214c48bfe64b090e | |
parent | b898502f46fcb8ee2a25a850cfe33351a8a67f26 (diff) | |
download | trace-cmd-0182ed722e6ae96d471caa546039202fb12cb36f.tar.gz |
trace-cmd report: Add --cpus option
Add the option --cpus to trace-cmd report to list the CPUs with data in
the trace file and then exit.
Link: https://lore.kernel.org/linux-trace-devel/20220314130955.420df3ef@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | Documentation/trace-cmd/trace-cmd-report.1.txt | 3 | ||||
-rw-r--r-- | tracecmd/trace-read.c | 28 | ||||
-rw-r--r-- | tracecmd/trace-usage.c | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/trace-cmd/trace-cmd-report.1.txt b/Documentation/trace-cmd/trace-cmd-report.1.txt index 18e1c5cd..aad8ab51 100644 --- a/Documentation/trace-cmd/trace-cmd-report.1.txt +++ b/Documentation/trace-cmd/trace-cmd-report.1.txt @@ -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. diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index 24177c44..df559d2a 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -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) { diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c index 5e96ca44..ea7d510d 100644 --- a/tracecmd/trace-usage.c +++ b/tracecmd/trace-usage.c @@ -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" |