sched: fix accounting of interrupts during guest execution on s390

Currently the scheduler checks for PF_VCPU to decide if this timeslice
has to be accounted as guest time. On s390 host interrupts are not
disabled during guest execution. This causes theses interrupts to be
accounted as guest time if CONFIG_VIRT_CPU_ACCOUNTING is set. Solution
is to check if an interrupt triggered account_system_time. As the tick
is timer interrupt based, we have to subtract hardirq_offset.

I tested the patch on s390 with CONFIG_VIRT_CPU_ACCOUNTING and on
x86_64. Seems to work.

CC: Avi Kivity <avi@qumranet.com>
CC: Laurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Christian Borntraeger and committed by Ingo Molnar 9778385d 99fee6d7

+2 -4
+2 -4
kernel/sched.c
··· 3390 struct rq *rq = this_rq(); 3391 cputime64_t tmp; 3392 3393 - if (p->flags & PF_VCPU) { 3394 - account_guest_time(p, cputime); 3395 - return; 3396 - } 3397 3398 p->stime = cputime_add(p->stime, cputime); 3399
··· 3390 struct rq *rq = this_rq(); 3391 cputime64_t tmp; 3392 3393 + if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) 3394 + return account_guest_time(p, cputime); 3395 3396 p->stime = cputime_add(p->stime, cputime); 3397