diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-06-06 20:34:21 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-06-06 20:34:21 +0200 |
commit | 021a7923928c27e1e4ad7d4a8c789bb77e00886f (patch) | |
tree | 9f8c65b2a0ab206a1452bb7b1f041bf20af54657 /ifpps.c | |
parent | b877698906563b42a4485202611e7f2df6fcd87f (diff) |
ifpps: Also display min hitter for IRQs
Also display the least heavy hitter for the relative and absolute IRQ
list. Also check that the number passed with -n is actually 1 or larger.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ifpps.c')
-rw-r--r-- | ifpps.c | 73 |
1 files changed, 50 insertions, 23 deletions
@@ -729,49 +729,74 @@ static void screen_percpu_states(WINDOW *screen, const struct ifstat *rel, if (top_cpus == cpus) top_cpus--; - for (i = 1; i < top_cpus; ++i) { - unsigned int idx = cpu_hits[i].idx; - - screen_percpu_states_one(screen, rel, voff, idx, ""); - } + for (i = 1; i < top_cpus; ++i) + screen_percpu_states_one(screen, rel, voff, cpu_hits[i].idx, ""); /* Display minimum hitter */ if (cpus != 1) screen_percpu_states_one(screen, rel, voff, cpu_hits[cpus - 1].idx, "-"); } +static void screen_percpu_irqs_rel_one(WINDOW *screen, const struct ifstat *rel, + int *voff, unsigned int idx, char *tag) +{ + int max_padd = padding_from_num(get_number_cpus()); + + mvwprintw(screen, (*voff)++, 2, + "cpu%*d%s:%s %14llu irqs/t " + "%15llu sirq rx/t " + "%15llu sirq tx/t ", max_padd, idx, + tag, strlen(tag) == 0 ? " " : "", + rel->irqs[idx], + rel->irqs_srx[idx], + rel->irqs_stx[idx]); +} + static void screen_percpu_irqs_rel(WINDOW *screen, const struct ifstat *rel, int top_cpus, int *voff) { int i; - int max_padd = padding_from_num(get_number_cpus()); + int cpus = get_number_cpus(); - for (i = 0; i < top_cpus; ++i) { - unsigned int idx = cpu_hits[i].idx; + screen_percpu_irqs_rel_one(screen, rel, voff, cpu_hits[0].idx, "+"); - mvwprintw(screen, (*voff)++, 2, - "cpu%*d: %14llu irqs/t " - "%15llu sirq rx/t " - "%15llu sirq tx/t ", max_padd, idx, - rel->irqs[idx], - rel->irqs_srx[idx], - rel->irqs_stx[idx]); - } + if (top_cpus == cpus) + top_cpus--; + + for (i = 1; i < top_cpus; ++i) + screen_percpu_irqs_rel_one(screen, rel, voff, cpu_hits[i].idx, ""); + + if (cpus != 1) + screen_percpu_irqs_rel_one(screen, rel, voff, cpu_hits[cpus - 1].idx, "-"); +} + +static void screen_percpu_irqs_abs_one(WINDOW *screen, const struct ifstat *abs, + int *voff, unsigned int idx, char *tag) +{ + int max_padd = padding_from_num(get_number_cpus()); + + mvwprintw(screen, (*voff)++, 2, + "cpu%*d%s:%s %14llu irqs", max_padd, idx, + tag, strlen(tag) == 0 ? " " : "", + abs->irqs[idx]); } static void screen_percpu_irqs_abs(WINDOW *screen, const struct ifstat *abs, int top_cpus, int *voff) { int i; - int max_padd = padding_from_num(get_number_cpus()); + int cpus = get_number_cpus(); - for (i = 0; i < top_cpus; ++i) { - unsigned int idx = cpu_hits[i].idx; + screen_percpu_irqs_abs_one(screen, abs, voff, cpu_hits[0].idx, "+"); - mvwprintw(screen, (*voff)++, 2, - "cpu%*d: %14llu irqs", max_padd, idx, - abs->irqs[idx]); - } + if (top_cpus == cpus) + top_cpus--; + + for (i = 1; i < top_cpus; ++i) + screen_percpu_irqs_abs_one(screen, abs, voff, cpu_hits[i].idx, ""); + + if (cpus != 1) + screen_percpu_irqs_abs_one(screen, abs, voff, cpu_hits[cpus - 1].idx, "-"); } static void screen_wireless(WINDOW *screen, const struct ifstat *rel, @@ -1056,6 +1081,8 @@ int main(int argc, char **argv) break; case 'n': top_cpus = strtoul(optarg, NULL, 10); + if (top_cpus < 1) + panic("Number of top hitter CPUs must be greater than 0"); break; case 'l': stats_loop = 1; |