aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRyota Ozaki <ozaki.ryota@gmail.com>2009-10-23 12:20:10 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-25 12:31:30 -0400
commitce0e7b28fb75cb003cfc8d0238613aaf1c55e797 (patch)
treee70bec2040045b68876d85036756bc046b5d2742 /kernel
parent0b9e31e9264f1bad89856afb96da1688292f13b4 (diff)
sched, cpuacct: Fix niced guest time accounting
CPU time of a guest is always accounted in 'user' time without concern for the nice value of its counterpart process although the guest is scheduled under the nice value. This patch fixes the defect and accounts cpu time of a niced guest in 'nice' time as same as a niced process. And also the patch adds 'guest_nice' to cpuacct. The value provides niced guest cpu time which is like 'nice' to 'user'. The original discussions can be found here: http://www.mail-archive.com/kvm@vger.kernel.org/msg23982.html http://www.mail-archive.com/kvm@vger.kernel.org/msg23860.html Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com> Acked-by: Avi Kivity <avi@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1256314810-7897-1-git-send-email-ozaki.ryota@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index e5205811c19e..67be4d0dddaa 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5017,8 +5017,13 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime,
5017 p->gtime = cputime_add(p->gtime, cputime); 5017 p->gtime = cputime_add(p->gtime, cputime);
5018 5018
5019 /* Add guest time to cpustat. */ 5019 /* Add guest time to cpustat. */
5020 cpustat->user = cputime64_add(cpustat->user, tmp); 5020 if (TASK_NICE(p) > 0) {
5021 cpustat->guest = cputime64_add(cpustat->guest, tmp); 5021 cpustat->nice = cputime64_add(cpustat->nice, tmp);
5022 cpustat->guest_nice = cputime64_add(cpustat->guest_nice, tmp);
5023 } else {
5024 cpustat->user = cputime64_add(cpustat->user, tmp);
5025 cpustat->guest = cputime64_add(cpustat->guest, tmp);
5026 }
5022} 5027}
5023 5028
5024/* 5029/*