aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorLaurent Vivier <Laurent.Vivier@bull.net>2007-10-15 11:00:19 -0400
committerIngo Molnar <mingo@elte.hu>2007-10-15 11:00:19 -0400
commit5e84cfde51cf303d368fcb48f22059f37b3872de (patch)
tree59a55bbc56944e06c8e5940a58ff667939b92f69 /fs/proc
parent6323469f9b72530eb90c96ba162cc70f2f4611de (diff)
sched: guest CPU accounting: add guest-CPU /proc/stat field
as recent CPUs introduce a third running state, after "user" and "system", we need a new field, "guest", in cpustat to store the time used by the CPU to run virtual CPU. Modify /proc/stat to display this new field. Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Acked-by: Avi Kivity <avi@qumranet.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/proc_misc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index bee251cb87c8..b872a01ad3af 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -443,6 +443,7 @@ static int show_stat(struct seq_file *p, void *v)
443 int i; 443 int i;
444 unsigned long jif; 444 unsigned long jif;
445 cputime64_t user, nice, system, idle, iowait, irq, softirq, steal; 445 cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
446 cputime64_t guest;
446 u64 sum = 0; 447 u64 sum = 0;
447 struct timespec boottime; 448 struct timespec boottime;
448 unsigned int *per_irq_sum; 449 unsigned int *per_irq_sum;
@@ -453,6 +454,7 @@ static int show_stat(struct seq_file *p, void *v)
453 454
454 user = nice = system = idle = iowait = 455 user = nice = system = idle = iowait =
455 irq = softirq = steal = cputime64_zero; 456 irq = softirq = steal = cputime64_zero;
457 guest = cputime64_zero;
456 getboottime(&boottime); 458 getboottime(&boottime);
457 jif = boottime.tv_sec; 459 jif = boottime.tv_sec;
458 460
@@ -467,6 +469,7 @@ static int show_stat(struct seq_file *p, void *v)
467 irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq); 469 irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
468 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); 470 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
469 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); 471 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
472 guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
470 for (j = 0; j < NR_IRQS; j++) { 473 for (j = 0; j < NR_IRQS; j++) {
471 unsigned int temp = kstat_cpu(i).irqs[j]; 474 unsigned int temp = kstat_cpu(i).irqs[j];
472 sum += temp; 475 sum += temp;
@@ -474,7 +477,7 @@ static int show_stat(struct seq_file *p, void *v)
474 } 477 }
475 } 478 }
476 479
477 seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu\n", 480 seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
478 (unsigned long long)cputime64_to_clock_t(user), 481 (unsigned long long)cputime64_to_clock_t(user),
479 (unsigned long long)cputime64_to_clock_t(nice), 482 (unsigned long long)cputime64_to_clock_t(nice),
480 (unsigned long long)cputime64_to_clock_t(system), 483 (unsigned long long)cputime64_to_clock_t(system),
@@ -482,7 +485,8 @@ static int show_stat(struct seq_file *p, void *v)
482 (unsigned long long)cputime64_to_clock_t(iowait), 485 (unsigned long long)cputime64_to_clock_t(iowait),
483 (unsigned long long)cputime64_to_clock_t(irq), 486 (unsigned long long)cputime64_to_clock_t(irq),
484 (unsigned long long)cputime64_to_clock_t(softirq), 487 (unsigned long long)cputime64_to_clock_t(softirq),
485 (unsigned long long)cputime64_to_clock_t(steal)); 488 (unsigned long long)cputime64_to_clock_t(steal),
489 (unsigned long long)cputime64_to_clock_t(guest));
486 for_each_online_cpu(i) { 490 for_each_online_cpu(i) {
487 491
488 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ 492 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
@@ -494,7 +498,9 @@ static int show_stat(struct seq_file *p, void *v)
494 irq = kstat_cpu(i).cpustat.irq; 498 irq = kstat_cpu(i).cpustat.irq;
495 softirq = kstat_cpu(i).cpustat.softirq; 499 softirq = kstat_cpu(i).cpustat.softirq;
496 steal = kstat_cpu(i).cpustat.steal; 500 steal = kstat_cpu(i).cpustat.steal;
497 seq_printf(p, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu\n", 501 guest = kstat_cpu(i).cpustat.guest;
502 seq_printf(p,
503 "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
498 i, 504 i,
499 (unsigned long long)cputime64_to_clock_t(user), 505 (unsigned long long)cputime64_to_clock_t(user),
500 (unsigned long long)cputime64_to_clock_t(nice), 506 (unsigned long long)cputime64_to_clock_t(nice),
@@ -503,7 +509,8 @@ static int show_stat(struct seq_file *p, void *v)
503 (unsigned long long)cputime64_to_clock_t(iowait), 509 (unsigned long long)cputime64_to_clock_t(iowait),
504 (unsigned long long)cputime64_to_clock_t(irq), 510 (unsigned long long)cputime64_to_clock_t(irq),
505 (unsigned long long)cputime64_to_clock_t(softirq), 511 (unsigned long long)cputime64_to_clock_t(softirq),
506 (unsigned long long)cputime64_to_clock_t(steal)); 512 (unsigned long long)cputime64_to_clock_t(steal),
513 (unsigned long long)cputime64_to_clock_t(guest));
507 } 514 }
508 seq_printf(p, "intr %llu", (unsigned long long)sum); 515 seq_printf(p, "intr %llu", (unsigned long long)sum);
509 516