aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksym Kryzhanovskyy <xmaks@email.cz>2010-11-06 01:56:19 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-06 01:56:19 +0100
commit0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5 (patch)
tree099f097653d6ddc9fc273d165d43afe658f167cc
parent9135fd26c485f57a76a94775a66ac4ccf5188990 (diff)
downloadbusybox-w32-0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5.tar.gz
busybox-w32-0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5.tar.bz2
busybox-w32-0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5.zip
powertop: code shrink
function old new delta process_timer_stats 490 449 -41 Signed-off-by: Maksym Kryzhanovskyy <xmaks@email.cz> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--procps/powertop.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/procps/powertop.c b/procps/powertop.c
index da7f05258..2f977a03b 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -399,6 +399,7 @@ static NOINLINE int process_timer_stats(void)
399 buf[0] = '\0'; 399 buf[0] = '\0';
400 totalticks = 0; 400 totalticks = 0;
401 401
402 n = 0;
402 fp = NULL; 403 fp = NULL;
403 if (!G.cant_enable_timer_stats) 404 if (!G.cant_enable_timer_stats)
404 fp = fopen_for_read("/proc/timer_stats"); 405 fp = fopen_for_read("/proc/timer_stats");
@@ -418,14 +419,24 @@ static NOINLINE int process_timer_stats(void)
418 const char *count, *process, *func; 419 const char *count, *process, *func;
419 char *p; 420 char *p;
420 int idx; 421 int idx;
422 unsigned cnt;
421 423
422 count = skip_whitespace(buf); 424 count = skip_whitespace(buf);
423 p = strchr(count, ','); 425 p = strchr(count, ',');
424 if (!p) 426 if (!p)
425 continue; 427 continue;
426 *p++ = '\0'; 428 *p++ = '\0';
427 if (strcmp(skip_non_whitespace(count), " total events") == 0) 429 cnt = bb_strtou(count, NULL, 10);
430 if (strcmp(skip_non_whitespace(count), " total events") == 0) {
431#if ENABLE_FEATURE_POWERTOP_PROCIRQ
432 n = cnt / G.total_cpus;
433 if (n > 0 && n < G.interrupt_0) {
434 sprintf(line, " <interrupt> : %s", "extra timer interrupt");
435 save_line(line, G.interrupt_0 - n);
436 }
437#endif
428 break; 438 break;
439 }
429 if (strchr(count, 'D')) 440 if (strchr(count, 'D'))
430 continue; /* deferred */ 441 continue; /* deferred */
431 p = skip_whitespace(p); /* points to pid now */ 442 p = skip_whitespace(p); /* points to pid now */
@@ -471,21 +482,11 @@ static NOINLINE int process_timer_stats(void)
471 sprintf(line, "%15.15s : %s", process, func); 482 sprintf(line, "%15.15s : %s", process, func);
472 //else 483 //else
473 // sprintf(line, "%s", process); 484 // sprintf(line, "%s", process);
474 save_line(line, bb_strtoull(count, NULL, 10)); 485 save_line(line, cnt);
475 } 486 }
476 fclose(fp); 487 fclose(fp);
477 } 488 }
478 489
479 n = 0;
480#if ENABLE_FEATURE_POWERTOP_PROCIRQ
481 if (strstr(buf, " total events")) {
482 n = bb_strtoull(buf, NULL, 10) / G.total_cpus;
483 if (n > 0 && n < G.interrupt_0) {
484 sprintf(line, " <interrupt> : %s", "extra timer interrupt");
485 save_line(line, G.interrupt_0 - n);
486 }
487 }
488#endif
489 return n; 490 return n;
490} 491}
491 492