diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2026-01-20 01:34:08 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2026-01-20 01:34:08 +0100 |
| commit | b96342799fa72e1cb78ba06e75341bef222cb227 (patch) | |
| tree | 28938cd3de086831ab162ee0db1961aed0dc820c | |
| parent | 3a8d2db1ced536f9f1c77f42f0b9845cf0c50e5b (diff) | |
| download | busybox-w32-b96342799fa72e1cb78ba06e75341bef222cb227.tar.gz busybox-w32-b96342799fa72e1cb78ba06e75341bef222cb227.tar.bz2 busybox-w32-b96342799fa72e1cb78ba06e75341bef222cb227.zip | |
vmstat: fix I/O, int and ctxt rates: need to be divided by secondsbusybox
function old new delta
vmstat_main 657 708 +51
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | procps/vmstat.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/procps/vmstat.c b/procps/vmstat.c index 26b438fd8..6cdd64111 100644 --- a/procps/vmstat.c +++ b/procps/vmstat.c | |||
| @@ -98,10 +98,11 @@ typedef unsigned data_t; | |||
| 98 | struct globals { | 98 | struct globals { |
| 99 | data_t data[NCOLS]; | 99 | data_t data[NCOLS]; |
| 100 | data_t prev[NCOLS]; | 100 | data_t prev[NCOLS]; |
| 101 | unsigned interval; | ||
| 101 | }; | 102 | }; |
| 102 | #define G (*(struct globals*)bb_common_bufsiz1) | 103 | #define G (*(struct globals*)bb_common_bufsiz1) |
| 103 | #define INIT_G() do { \ | 104 | #define INIT_G() do { \ |
| 104 | /* memset(&G, 0, sizeof G); */ \ | 105 | memset(&G, 0, sizeof G); \ |
| 105 | } while (0) | 106 | } while (0) |
| 106 | 107 | ||
| 107 | 108 | ||
| @@ -435,6 +436,9 @@ static void print_row(const data_t data[NCOLS], | |||
| 435 | */ | 436 | */ |
| 436 | if ((col.width>>1) == 4/2) { | 437 | if ((col.width>>1) == 4/2) { |
| 437 | char buf45[6]; | 438 | char buf45[6]; |
| 439 | /* si/so/bi/bo/in/cs display rate per second (checked on 4.0.4): */ | ||
| 440 | if (G.interval != 0) | ||
| 441 | value /= G.interval; | ||
| 438 | if (col.width == 4) | 442 | if (col.width == 4) |
| 439 | smart_ulltoa4(value, buf45, " kmgtpezy")[0] = '\0'; | 443 | smart_ulltoa4(value, buf45, " kmgtpezy")[0] = '\0'; |
| 440 | else | 444 | else |
| @@ -516,7 +520,6 @@ int vmstat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
| 516 | int vmstat_main(int argc UNUSED_PARAM, char **argv) | 520 | int vmstat_main(int argc UNUSED_PARAM, char **argv) |
| 517 | { | 521 | { |
| 518 | int opt; | 522 | int opt; |
| 519 | unsigned interval; | ||
| 520 | int count; | 523 | int count; |
| 521 | unsigned height; | 524 | unsigned height; |
| 522 | int row; | 525 | int row; |
| @@ -527,10 +530,10 @@ int vmstat_main(int argc UNUSED_PARAM, char **argv) | |||
| 527 | opt = getopt32(argv, "n"); | 530 | opt = getopt32(argv, "n"); |
| 528 | argv += optind; | 531 | argv += optind; |
| 529 | 532 | ||
| 530 | interval = 0; | 533 | /*G.interval = 0;*/ |
| 531 | count = 1; | 534 | count = 1; |
| 532 | if (*argv) { | 535 | if (*argv) { |
| 533 | interval = xatoi_positive(*argv); /* 4.0.4 requires nonzero, we don't care */ | 536 | G.interval = xatoi_positive(*argv); /* 4.0.4 requires nonzero, we don't care */ |
| 534 | count = 0; /* "infinity" */ | 537 | count = 0; /* "infinity" */ |
| 535 | argv++; | 538 | argv++; |
| 536 | if (*argv) { | 539 | if (*argv) { |
| @@ -571,7 +574,7 @@ int vmstat_main(int argc UNUSED_PARAM, char **argv) | |||
| 571 | break; | 574 | break; |
| 572 | 575 | ||
| 573 | memcpy(G.prev, G.data, sizeof(G.prev)); | 576 | memcpy(G.prev, G.data, sizeof(G.prev)); |
| 574 | sleep(interval); | 577 | sleep(G.interval); |
| 575 | } | 578 | } |
| 576 | 579 | ||
| 577 | return EXIT_SUCCESS; | 580 | return EXIT_SUCCESS; |
