Add the options to select c-states, p-states and wakeup output.

--idle, -c      : show c-states
--frequency, -p : show p-states
--wakeup, -w    : show wakeup sources

Signed-off-by: Daniel Lezcano <daniel.lezc...@linaro.org>
---
 README     |    7 ++++++-
 idlestat.c |   35 +++++++++++++++++++++++++++--------
 idlestat.h |    4 ++++
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/README b/README
index b9edf4f..dccce36 100644
--- a/README
+++ b/README
@@ -38,9 +38,14 @@ Example Usage
 Trace mode:
 sudo ./idlestat --trace -f /tmp/mytrace -t 10
 
-Reporing mode (/tmp/mytrace already contains traces):
+Reporting mode (/tmp/mytrace already contains traces):
 sudo ./idlestat --import -f /tmp/mytrace
 
 Trace mode with workload (e.g. sleep, cyclictest):
 sudo ./idlestat --trace -f /tmp/mytrace -t 10 -- /bin/sleep 10
 sudo ./idlestat --trace -f /tmp/myoutput -t 10 -- cyclictest -t 4 -i 2000 -q 
-D 5
+
+Selective trace output
+sudo ./idlestate --import -f /tmp/mytrace -w
+sudo ./idlestate --import -f /tmp/mytrace -c -p
+sudo ./idlestate --import -f /tmp/mytrace -p -w
\ No newline at end of file
diff --git a/idlestat.c b/idlestat.c
index 3fe2af6..94e570a 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1087,7 +1087,7 @@ static void help(const char *cmd)
 {
        fprintf(stderr,
                "\nUsage:\nTrace mode: %s --trace -f|--trace-file <filename>"
-               " -t|--duration <seconds> ",
+               " -t|--duration <seconds> -c|--idle -p|--frequency -w|--wakeup",
                basename(cmd));
        fprintf(stderr,
                "\nReporting mode: %s --import -f|--trace-file <filename>",
@@ -1113,6 +1113,9 @@ int getoptions(int argc, char *argv[], struct 
program_options *options)
                { "duration",    required_argument, NULL, 't' },
                { "version",     no_argument,       NULL, 'V' },
                { "verbose",     no_argument,       NULL, 'v' },
+               { "idle",        no_argument,       NULL, 'c' },
+               { "frequency",   no_argument,       NULL, 'p' },
+               { "wakeup",      no_argument,       NULL, 'w' },
                { 0, 0, 0, 0 }
        };
        int c;
@@ -1125,7 +1128,7 @@ int getoptions(int argc, char *argv[], struct 
program_options *options)
 
                int optindex = 0;
 
-               c = getopt_long(argc, argv, ":df:ht:Vv",
+               c = getopt_long(argc, argv, ":df:ht:cpwVv",
                                long_options, &optindex);
                if (c == -1)
                        break;
@@ -1141,6 +1144,15 @@ int getoptions(int argc, char *argv[], struct 
program_options *options)
                case 't':
                        options->duration = atoi(optarg);
                        break;
+               case 'c':
+                       options->display |= IDLE_DISPLAY;
+                       break;
+               case 'p':
+                       options->display |= FREQUENCY_DISPLAY;
+                       break;
+               case 'w':
+                       options->display |= WAKEUP_DISPLAY;
+                       break;
                case 'V':
                        version(argv[0]);
                        exit(0);
@@ -1180,6 +1192,9 @@ int getoptions(int argc, char *argv[], struct 
program_options *options)
                }
        }
 
+       if (options->display == 0)
+               options->display = IDLE_DISPLAY;
+
        return optind;
 }
 
@@ -1429,13 +1444,17 @@ int main(int argc, char *argv[], char *const envp[])
         */
        if (0 == establish_idledata_to_topo(datas)) {
 
-               display_cstates_header();
-               dump_cpu_topo_info(display_cstates, 0);
-               display_cstates_footer();
+               if (options.display & IDLE_DISPLAY) {
+                       display_cstates_header();
+                       dump_cpu_topo_info(display_cstates, 0);
+                       display_cstates_footer();
+               }
 
-               display_pstates_header();
-               dump_cpu_topo_info(display_pstates, 1);
-               display_pstates_footer();
+               if (options.display & FREQUENCY_DISPLAY) {
+                       display_pstates_header();
+                       dump_cpu_topo_info(display_pstates, 1);
+                       display_pstates_footer();
+               }
        }
 
        release_cpu_topo_cstates();
diff --git a/idlestat.h b/idlestat.h
index 31df587..1d5f961 100644
--- a/idlestat.h
+++ b/idlestat.h
@@ -129,10 +129,14 @@ enum formats {
 struct program_options {
        int mode;
        int format;
+       int display;
        unsigned int duration;
        char *filename;
        int verbose;
 };
 
+#define IDLE_DISPLAY      0x1
+#define FREQUENCY_DISPLAY 0x2
+#define WAKEUP_DISPLAY    0x4
 
 #endif
-- 
1.7.9.5


_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to