diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2023-12-20 12:23:31 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-12-31 16:28:53 +0100 |
commit | 01e80ff9ebaf42f2fb9b4ddddc75d37bc9a403aa (patch) | |
tree | 20603f271ebe6d7b0b321382eb280bfcd688abb3 | |
parent | 789ccac7d9d1a9e433570ac9628992a01f946643 (diff) | |
download | busybox-w32-01e80ff9ebaf42f2fb9b4ddddc75d37bc9a403aa.tar.gz busybox-w32-01e80ff9ebaf42f2fb9b4ddddc75d37bc9a403aa.tar.bz2 busybox-w32-01e80ff9ebaf42f2fb9b4ddddc75d37bc9a403aa.zip |
time: fix max resident set size unit
The ru_maxrss is already in Kbytes and not pages.
function old new delta
ptok 21 - -21
time_main 1261 1217 -44
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes
fixes: https://bugs.busybox.net/show_bug.cgi?id=15751
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/time.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/miscutils/time.c b/miscutils/time.c index 5a8fa4c0b..4b1b043c3 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -111,6 +111,7 @@ static void printargv(char *const *argv) | |||
111 | } while (*++argv); | 111 | } while (*++argv); |
112 | } | 112 | } |
113 | 113 | ||
114 | #ifdef UNUSED | ||
114 | /* Return the number of kilobytes corresponding to a number of pages PAGES. | 115 | /* Return the number of kilobytes corresponding to a number of pages PAGES. |
115 | (Actually, we use it to convert pages*ticks into kilobytes*ticks.) | 116 | (Actually, we use it to convert pages*ticks into kilobytes*ticks.) |
116 | 117 | ||
@@ -136,6 +137,7 @@ static unsigned long ptok(const unsigned pagesize, const unsigned long pages) | |||
136 | return tmp / 1024; /* then smaller. */ | 137 | return tmp / 1024; /* then smaller. */ |
137 | } | 138 | } |
138 | #undef pagesize | 139 | #undef pagesize |
140 | #endif /* UNUSED */ | ||
139 | 141 | ||
140 | /* summarize: Report on the system use of a command. | 142 | /* summarize: Report on the system use of a command. |
141 | 143 | ||
@@ -250,9 +252,13 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
250 | printargv(command); | 252 | printargv(command); |
251 | break; | 253 | break; |
252 | case 'D': /* Average unshared data size. */ | 254 | case 'D': /* Average unshared data size. */ |
255 | /* (linux kernel sets ru_idrss/isrss/ixrss to 0, | ||
256 | * docs say the value is in kbytes, so ptok() is wrong) */ | ||
253 | printf("%lu", | 257 | printf("%lu", |
254 | (ptok(pagesize, (UL) resp->ru.ru_idrss) + | 258 | (/*ptok(pagesize,*/ (UL) resp->ru.ru_idrss + |
255 | ptok(pagesize, (UL) resp->ru.ru_isrss)) / cpu_ticks); | 259 | (UL) resp->ru.ru_isrss |
260 | ) / cpu_ticks | ||
261 | ); | ||
256 | break; | 262 | break; |
257 | case 'E': { /* Elapsed real (wall clock) time. */ | 263 | case 'E': { /* Elapsed real (wall clock) time. */ |
258 | unsigned seconds = resp->elapsed_ms / 1000; | 264 | unsigned seconds = resp->elapsed_ms / 1000; |
@@ -275,13 +281,17 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
275 | printf("%lu", resp->ru.ru_inblock); | 281 | printf("%lu", resp->ru.ru_inblock); |
276 | break; | 282 | break; |
277 | case 'K': /* Average mem usage == data+stack+text. */ | 283 | case 'K': /* Average mem usage == data+stack+text. */ |
284 | /* (linux kernel sets ru_idrss/isrss/ixrss to 0, | ||
285 | * docs say the value is in kbytes, so ptok() is wrong) */ | ||
278 | printf("%lu", | 286 | printf("%lu", |
279 | (ptok(pagesize, (UL) resp->ru.ru_idrss) + | 287 | (/*ptok(pagesize,*/ (UL) resp->ru.ru_idrss + |
280 | ptok(pagesize, (UL) resp->ru.ru_isrss) + | 288 | (UL) resp->ru.ru_isrss + |
281 | ptok(pagesize, (UL) resp->ru.ru_ixrss)) / cpu_ticks); | 289 | (UL) resp->ru.ru_ixrss |
290 | ) / cpu_ticks | ||
291 | ); | ||
282 | break; | 292 | break; |
283 | case 'M': /* Maximum resident set size. */ | 293 | case 'M': /* Maximum resident set size. */ |
284 | printf("%lu", ptok(pagesize, (UL) resp->ru.ru_maxrss)); | 294 | printf("%lu", (UL) resp->ru.ru_maxrss); |
285 | break; | 295 | break; |
286 | case 'O': /* Outputs. */ | 296 | case 'O': /* Outputs. */ |
287 | printf("%lu", resp->ru.ru_oublock); | 297 | printf("%lu", resp->ru.ru_oublock); |
@@ -334,7 +344,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
334 | printf("%lu", resp->ru.ru_nswap); | 344 | printf("%lu", resp->ru.ru_nswap); |
335 | break; | 345 | break; |
336 | case 'X': /* Average shared text size. */ | 346 | case 'X': /* Average shared text size. */ |
337 | printf("%lu", ptok(pagesize, (UL) resp->ru.ru_ixrss) / cpu_ticks); | 347 | printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_ixrss / cpu_ticks); |
338 | break; | 348 | break; |
339 | case 'Z': /* Page size. */ | 349 | case 'Z': /* Page size. */ |
340 | printf("%u", pagesize); | 350 | printf("%u", pagesize); |
@@ -351,7 +361,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
351 | printf("%lu", resp->ru.ru_nsignals); | 361 | printf("%lu", resp->ru.ru_nsignals); |
352 | break; | 362 | break; |
353 | case 'p': /* Average stack segment. */ | 363 | case 'p': /* Average stack segment. */ |
354 | printf("%lu", ptok(pagesize, (UL) resp->ru.ru_isrss) / cpu_ticks); | 364 | printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_isrss / cpu_ticks); |
355 | break; | 365 | break; |
356 | case 'r': /* Incoming socket messages received. */ | 366 | case 'r': /* Incoming socket messages received. */ |
357 | printf("%lu", resp->ru.ru_msgrcv); | 367 | printf("%lu", resp->ru.ru_msgrcv); |
@@ -360,7 +370,7 @@ static void summarize(const char *fmt, char **command, resource_t *resp) | |||
360 | printf("%lu", resp->ru.ru_msgsnd); | 370 | printf("%lu", resp->ru.ru_msgsnd); |
361 | break; | 371 | break; |
362 | case 't': /* Average resident set size. */ | 372 | case 't': /* Average resident set size. */ |
363 | printf("%lu", ptok(pagesize, (UL) resp->ru.ru_idrss) / cpu_ticks); | 373 | printf("%lu", /*ptok(pagesize,*/ (UL) resp->ru.ru_idrss / cpu_ticks); |
364 | break; | 374 | break; |
365 | case 'w': /* Voluntary context switches. */ | 375 | case 'w': /* Voluntary context switches. */ |
366 | printf("%lu", resp->ru.ru_nvcsw); | 376 | printf("%lu", resp->ru.ru_nvcsw); |