The display functions are tied together in the code. Split this, so we can
choose each subsystem to display separately.

Signed-off-by: Daniel Lezcano <daniel.lezc...@linaro.org>
---
 idlestat.c |  102 ++++++++++++++++++++++++++++++++++++++----------------------
 topology.c |   11 ++++---
 2 files changed, 71 insertions(+), 42 deletions(-)

diff --git a/idlestat.c b/idlestat.c
index 94e570a..77f6d0a 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -75,34 +75,6 @@ static void charrep(char c, int count)
                printf("%c", c);
 }
 
-static void display_cstates_header(void)
-{
-       charrep('-', 80);
-       printf("\n");
-
-       printf("| C-state  |   min    |   max    |   avg    |   total  | hits  
|  over | under |\n");
-}
-
-static void display_cstates_footer(void)
-{
-       charrep('-', 80);
-       printf("\n\n");
-}
-
-static void display_pstates_header(void)
-{
-       charrep('-', 64);
-       printf("\n");
-
-       printf("| P-state  |   min    |   max    |   avg    |   total  | hits  
|\n");
-}
-
-static void display_pstates_footer(void)
-{
-       charrep('-', 64);
-       printf("\n\n");
-}
-
 static void display_cpu_header(char *cpu, int length)
 {
        charrep('-', length);
@@ -145,6 +117,20 @@ static void display_factored_freq(int freq, int align)
        }
 }
 
+static void display_cstates_header(void)
+{
+       charrep('-', 80);
+       printf("\n");
+
+       printf("| C-state  |   min    |   max    |   avg    |   total  | hits  
|  over | under |\n");
+}
+
+static void display_cstates_footer(void)
+{
+       charrep('-', 80);
+       printf("\n\n");
+}
+
 static int display_cstates(void *arg, char *cpu)
 {
        int i;
@@ -184,6 +170,20 @@ static int display_cstates(void *arg, char *cpu)
        return 0;
 }
 
+static void display_pstates_header(void)
+{
+       charrep('-', 64);
+       printf("\n");
+
+       printf("| P-state  |   min    |   max    |   avg    |   total  | hits  
|\n");
+}
+
+static void display_pstates_footer(void)
+{
+       charrep('-', 64);
+       printf("\n\n");
+}
+
 static int display_pstates(void *arg, char *cpu)
 {
        int i;
@@ -225,19 +225,41 @@ static int display_pstates(void *arg, char *cpu)
        return 0;
 }
 
-static int display_wakeup_sources(struct wakeup_info *wakeinfo, char *str)
+static void display_wakeup_header(void)
+{
+       charrep('-', 44);
+       printf("\n");
+
+       printf("| Wakeup |  #  |       Name      |  Count  |\n");
+}
+
+static void display_wakeup_footer(void)
+{
+       charrep('-', 44);
+       printf("\n\n");
+}
+
+static int display_wakeup(void *arg, char *cpu)
 {
        int i;
+       bool cpu_header = false;
+       struct cpuidle_cstates *cstates = arg;
+       struct wakeup_info *wakeinfo = &cstates->wakeinfo;
        struct wakeup_irq *irqinfo = wakeinfo->irqinfo;
 
-       printf("%s wakeups \tname \t\tcount\tunexpected\n", str);
        for (i = 0; i < wakeinfo->nrdata; i++, irqinfo++) {
-               printf("%*c %s%03d\t%-15.15s\t%d\t%d\n", (int)strlen(str),
-                      ' ',
+
+               if (!cpu_header) {
+                       display_cpu_header(cpu, 44);
+                       cpu_header = true;
+                       charrep('-', 44);
+                       printf("\n");
+               }
+
+               printf("| %-6s | %-3d | %15.15s | %7d |\n",
                       (irqinfo->irq_type < IRQ_TYPE_MAX) ?
-                      irq_type_name[irqinfo->irq_type] : "NULL",
-                      irqinfo->id, irqinfo->name, irqinfo->count,
-                      irqinfo->not_predicted);
+                      irq_type_name[irqinfo->irq_type] : "???",
+                      irqinfo->id, irqinfo->name, irqinfo->count);
        }
 
        return 0;
@@ -1446,15 +1468,21 @@ int main(int argc, char *argv[], char *const envp[])
 
                if (options.display & IDLE_DISPLAY) {
                        display_cstates_header();
-                       dump_cpu_topo_info(display_cstates, 0);
+                       dump_cpu_topo_info(display_cstates, 1);
                        display_cstates_footer();
                }
 
                if (options.display & FREQUENCY_DISPLAY) {
                        display_pstates_header();
-                       dump_cpu_topo_info(display_pstates, 1);
+                       dump_cpu_topo_info(display_pstates, 0);
                        display_pstates_footer();
                }
+
+               if (options.display & WAKEUP_DISPLAY) {
+                       display_wakeup_header();
+                       dump_cpu_topo_info(display_wakeup, 1);
+                       display_wakeup_footer();
+               }
        }
 
        release_cpu_topo_cstates();
diff --git a/topology.c b/topology.c
index 5bf88a1..00c1fe1 100644
--- a/topology.c
+++ b/topology.c
@@ -449,7 +449,7 @@ int establish_idledata_to_topo(struct cpuidle_datas *datas)
        return 0;
 }
 
-int dump_cpu_topo_info(int (*dump)(void *, char *), int pstate)
+int dump_cpu_topo_info(int (*dump)(void *, char *), int cstate)
 {
        struct cpu_physical *s_phy;
        struct cpu_core     *s_core;
@@ -461,11 +461,11 @@ int dump_cpu_topo_info(int (*dump)(void *, char *), int 
pstate)
 
                sprintf(tmp, "cluster%c", s_phy->physical_id + 'A');
 
-               if (!pstate)
+               if (cstate)
                        dump(s_phy->cstates, tmp);
 
                list_for_each_entry(s_core, &s_phy->core_head, list_core) {
-                       if (s_core->is_ht && !pstate) {
+                       if (s_core->is_ht && cstate) {
                                sprintf(tmp, "core%d", s_core->core_id);
                                dump(s_core->cstates, tmp);
                        }
@@ -473,8 +473,9 @@ int dump_cpu_topo_info(int (*dump)(void *, char *), int 
pstate)
                        list_for_each_entry(s_cpu, &s_core->cpu_head,
                                            list_cpu) {
                                sprintf(tmp, "cpu%d", s_cpu->cpu_id);
-                               dump(pstate ? s_cpu->pstates :
-                                    s_cpu->cstates, tmp);
+                               dump(cstate ?
+                                    (void *)s_cpu->cstates :
+                                    (void *)s_cpu->pstates, tmp);
                        }
                }
        }
-- 
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