]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: display number of new interupts in-between updates
authorSami Kerola <kerolasa@iki.fi>
Fri, 21 Feb 2020 22:28:43 +0000 (22:28 +0000)
committerSami Kerola <kerolasa@iki.fi>
Sat, 22 Feb 2020 21:43:54 +0000 (21:43 +0000)
The rirst output is total count followed by number of interupts since
previous screen update.  This is how the irqtop worked before libsmartcols
was added to the command.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/irqtop.1
sys-utils/irqtop.c

index 4353c23f40ee97abf544d95c0b1a19c3de8bce91..97e24f6bdec013b832689ff26a607387d10c93cb 100644 (file)
@@ -27,6 +27,7 @@ interactive mode will make the ncurses output to be ordered accordingly.
 .PP
 .RS
 .PD 0
+.\" Key commands are in alphabetical order
 .TP
 .B c
 sort by increase count of each interrupt (the default)
@@ -39,6 +40,9 @@ sort by name
 .TP
 .B q Q
 stop updates and exit program
+.TP
+.B t
+alterate displaying delta and totals count
 .PD
 .RE
 .TP
index ef3b275db7c053a386e508cb7aa54274cb33e6b7..bdb8c3b8772e857bb3e8ff22c0849df403858b81 100644 (file)
@@ -119,7 +119,7 @@ struct irqtop_ctl {
        struct timeval uptime_tv;
        int (*sort_func)(const struct irq_info *, const struct irq_info *);
        long smp_num_cpus;
-       struct irq_stat *last_stat;
+       struct irq_stat *prev_stat;
        char *hostname;
        struct libscols_table *table;
        struct libscols_line *outline;
@@ -129,6 +129,7 @@ struct irqtop_ctl {
                json:1,
                no_headings:1,
                request_exit:1,
+               display_total:1,
                run_once:1;
 };
 
@@ -396,6 +397,8 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_("  c:   sort by increase count of each interrupt\n"), stdout);
        fputs(_("  i:   sort by default interrupts from proc interrupt\n"), stdout);
        fputs(_("  n:   sort by name\n"), stdout);
+       fputs(_("  q Q: stop updates and exit program\n"), stdout);
+       fputs(_("  t:   alterate displaying delta and totals count\n"), stdout);
 
        fputs(USAGE_COLUMNS, stdout);
        for (i = 0; i < ARRAY_SIZE(infos); i++)
@@ -431,6 +434,9 @@ static void parse_input(struct irqtop_ctl *ctl, char c)
        case 'n':
                ctl->sort_func = sort_name;
                break;
+       case 't':
+               ctl->display_total = !ctl->display_total;
+               break;
        case 'q':
        case 'Q':
                ctl->request_exit = 1;
@@ -496,8 +502,13 @@ static int update_screen(struct irqtop_ctl *ctl)
        size = sizeof(*stat->irq_info) * stat->nr_irq;
        result = xmalloc(size);
        memcpy(result, stat->irq_info, size);
+       if (!ctl->display_total) {
+               for (index = 0; ctl->prev_stat && index < stat->nr_irq; index++)
+                       result[index].count -= ctl->prev_stat->irq_info[index].count;
+       }
        sort_result(ctl, result, stat->nr_irq);
-       for (index = 0; index < choose_smaller(ctl->rows - RESERVE_ROWS, stat->nr_irq); index++) {
+       size = choose_smaller(ctl->rows - RESERVE_ROWS, stat->nr_irq);
+       for (index = 0; index < size; index++) {
                curr = result + index;
                add_scols_line(ctl, curr);
        }
@@ -514,6 +525,11 @@ static int update_screen(struct irqtop_ctl *ctl)
        }
        scols_unref_table(ctl->table);
 
+       if (!ctl->display_total) {
+               if (ctl->prev_stat)
+                       free_irqinfo(ctl->prev_stat);
+               ctl->prev_stat = stat;
+       }
        return 0;
 }
 
@@ -695,7 +711,7 @@ int main(int argc, char **argv)
        else
                event_loop(&ctl);
 
-       free_irqinfo(ctl.last_stat);
+       free_irqinfo(ctl.prev_stat);
        free(ctl.hostname);
 
        if (is_tty)