diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-30 13:55:35 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-30 13:55:35 +0200 |
| commit | 3fb4a5e6d86e52014502391d8dca25befa4ff9b4 (patch) | |
| tree | 0ac8d9f613712106b2710033431743fa9b5b64d1 | |
| parent | 9bb0510b9b065cf81ee6f9e4e34bea8a32915eed (diff) | |
| download | busybox-w32-3fb4a5e6d86e52014502391d8dca25befa4ff9b4.tar.gz busybox-w32-3fb4a5e6d86e52014502391d8dca25befa4ff9b4.tar.bz2 busybox-w32-3fb4a5e6d86e52014502391d8dca25befa4ff9b4.zip | |
mpstat: better fix for IRQ counts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | procps/mpstat.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/procps/mpstat.c b/procps/mpstat.c index d19abee97..1199b98dd 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
| @@ -93,8 +93,9 @@ struct globals { | |||
| 93 | unsigned hz; | 93 | unsigned hz; |
| 94 | unsigned cpu_bitmap_len; | 94 | unsigned cpu_bitmap_len; |
| 95 | smallint p_option; | 95 | smallint p_option; |
| 96 | smallint header_done; | 96 | // 9.0.6 does not do it. Try "mpstat -A 1 2" - headers are repeated! |
| 97 | smallint avg_header_done; | 97 | //smallint header_done; |
| 98 | //smallint avg_header_done; | ||
| 98 | unsigned char *cpu_bitmap; /* Bit 0: global, bit 1: 1st proc... */ | 99 | unsigned char *cpu_bitmap; /* Bit 0: global, bit 1: 1st proc... */ |
| 99 | data_t global_uptime[3]; | 100 | data_t global_uptime[3]; |
| 100 | data_t per_cpu_uptime[3]; | 101 | data_t per_cpu_uptime[3]; |
| @@ -206,7 +207,7 @@ static void write_irqcpu_stats(struct stats_irqcpu *per_cpu_stats[], | |||
| 206 | printf("\n%-11s CPU", prev_str); | 207 | printf("\n%-11s CPU", prev_str); |
| 207 | { | 208 | { |
| 208 | /* A bit complex code to "buy back" space if one header is too wide. | 209 | /* A bit complex code to "buy back" space if one header is too wide. |
| 209 | * Here's how it looks like. BLOCK_IOPOLL eating too much, | 210 | * Here's how it looks like. BLOCK_IOPOLL eats too much space, |
| 210 | * and latter headers use smaller width to compensate: | 211 | * and latter headers use smaller width to compensate: |
| 211 | * ...BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HRTIMER/s RCU/s | 212 | * ...BLOCK/s BLOCK_IOPOLL/s TASKLET/s SCHED/s HRTIMER/s RCU/s |
| 212 | * ... 2.32 0.00 0.01 17.58 0.14 141.96 | 213 | * ... 2.32 0.00 0.01 17.58 0.14 141.96 |
| @@ -328,13 +329,13 @@ static void write_stats_core(int prev, int current, | |||
| 328 | /* Print CPU stats */ | 329 | /* Print CPU stats */ |
| 329 | if (display_opt(D_CPU)) { | 330 | if (display_opt(D_CPU)) { |
| 330 | 331 | ||
| 331 | /* This is done exactly once */ | 332 | ///* This is done exactly once */ |
| 332 | if (!G.header_done) { | 333 | //if (!G.header_done) { |
| 333 | printf("\n%-11s CPU %%usr %%nice %%sys %%iowait %%irq %%soft %%steal %%guest %%idle\n", | 334 | printf("\n%-11s CPU %%usr %%nice %%sys %%iowait %%irq %%soft %%steal %%guest %%idle\n", |
| 334 | prev_str | 335 | prev_str |
| 335 | ); | 336 | ); |
| 336 | G.header_done = 1; | 337 | // G.header_done = 1; |
| 337 | } | 338 | //} |
| 338 | 339 | ||
| 339 | for (cpu = 0; cpu <= G.cpu_nr; cpu++) { | 340 | for (cpu = 0; cpu <= G.cpu_nr; cpu++) { |
| 340 | data_t per_cpu_itv; | 341 | data_t per_cpu_itv; |
| @@ -389,11 +390,11 @@ static void write_stats_core(int prev, int current, | |||
| 389 | /* Print total number of IRQs per CPU */ | 390 | /* Print total number of IRQs per CPU */ |
| 390 | if (display_opt(D_IRQ_SUM)) { | 391 | if (display_opt(D_IRQ_SUM)) { |
| 391 | 392 | ||
| 392 | /* Print average header, this is done exactly once */ | 393 | ///* Print average header, this is done exactly once */ |
| 393 | if (!G.avg_header_done) { | 394 | //if (!G.avg_header_done) { |
| 394 | printf("\n%-11s CPU intr/s\n", prev_str); | 395 | printf("\n%-11s CPU intr/s\n", prev_str); |
| 395 | G.avg_header_done = 1; | 396 | // G.avg_header_done = 1; |
| 396 | } | 397 | //} |
| 397 | 398 | ||
| 398 | for (cpu = 0; cpu <= G.cpu_nr; cpu++) { | 399 | for (cpu = 0; cpu <= G.cpu_nr; cpu++) { |
| 399 | data_t per_cpu_itv; | 400 | data_t per_cpu_itv; |
| @@ -526,13 +527,8 @@ static void get_cpu_statistics(struct stats_cpu *cpu, data_t *up, data_t *up0) | |||
| 526 | static void get_irqs_from_stat(struct stats_irq *irq) | 527 | static void get_irqs_from_stat(struct stats_irq *irq) |
| 527 | { | 528 | { |
| 528 | FILE *fp; | 529 | FILE *fp; |
| 529 | unsigned cpu; | ||
| 530 | char buf[1024]; | 530 | char buf[1024]; |
| 531 | 531 | ||
| 532 | for (cpu = 1; cpu <= G.cpu_nr; cpu++) { | ||
| 533 | irq->irq_nr = 0; | ||
| 534 | } | ||
| 535 | |||
| 536 | fp = fopen_for_read(PROCFS_STAT); | 532 | fp = fopen_for_read(PROCFS_STAT); |
| 537 | if (!fp) | 533 | if (!fp) |
| 538 | return; | 534 | return; |
| @@ -565,8 +561,7 @@ static void get_irqs_from_interrupts(const char *fname, | |||
| 565 | int cpu_index[G.cpu_nr]; | 561 | int cpu_index[G.cpu_nr]; |
| 566 | int iindex; | 562 | int iindex; |
| 567 | 563 | ||
| 568 | // Moved to get_irqs_from_stat(), which is called once, not twice, | 564 | // Moved to caller. |
| 569 | // unlike get_irqs_from_interrupts(). | ||
| 570 | // Otherwise reading of /proc/softirqs | 565 | // Otherwise reading of /proc/softirqs |
| 571 | // was resetting counts to 0 after we painstakingly collected them from | 566 | // was resetting counts to 0 after we painstakingly collected them from |
| 572 | // /proc/interrupts. Which resulted in: | 567 | // /proc/interrupts. Which resulted in: |
| @@ -756,9 +751,15 @@ static void main_loop(void) | |||
| 756 | if (display_opt(D_IRQ_SUM)) | 751 | if (display_opt(D_IRQ_SUM)) |
| 757 | get_irqs_from_stat(G.st_irq[current]); | 752 | get_irqs_from_stat(G.st_irq[current]); |
| 758 | 753 | ||
| 759 | if (display_opt(D_IRQ_SUM | D_IRQ_CPU)) | 754 | if (display_opt(D_IRQ_SUM | D_IRQ_CPU)) { |
| 755 | int cpu; | ||
| 756 | for (cpu = 1; cpu <= G.cpu_nr; cpu++) { | ||
| 757 | G.st_irq[current][cpu].irq_nr = 0; | ||
| 758 | } | ||
| 759 | /* accumulates .irq_nr */ | ||
| 760 | get_irqs_from_interrupts(PROCFS_INTERRUPTS, G.st_irqcpu, | 760 | get_irqs_from_interrupts(PROCFS_INTERRUPTS, G.st_irqcpu, |
| 761 | G.irqcpu_nr, current); | 761 | G.irqcpu_nr, current); |
| 762 | } | ||
| 762 | 763 | ||
| 763 | if (display_opt(D_SOFTIRQS)) | 764 | if (display_opt(D_SOFTIRQS)) |
| 764 | get_irqs_from_interrupts(PROCFS_SOFTIRQS, | 765 | get_irqs_from_interrupts(PROCFS_SOFTIRQS, |
