From: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
To: Christian Borntraeger
<borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel
<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH v2] kvm: Fix accounting of interrupts during guest execution on s390
Date: Thu, 15 Nov 2007 18:08:06 +0100 [thread overview]
Message-ID: <1195146486.4704.60.camel@frecb07144> (raw)
In-Reply-To: <200711151656.44935.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 4497 bytes --]
Le jeudi 15 novembre 2007 à 16:56 +0100, Christian Borntraeger a écrit :
> Am Donnerstag, 15. November 2007 schrieb Laurent Vivier:
> > If I remember correctly time accounting on s390 is more accurate than on
> > x86 ?
>
> Yes. its done during context switches and resolution is microsecond.
>
> > Because on x86, as we make the kvm_guest_exit() after local_irq_enable()
> > we can also have IRQ with PF_VCPU set... and we discussed a lot on
> > probability to know if it was good or not. And on x86 it seems good
> > because it is already working like that with system and user time (we
> > account time to the space where tick appears).
> > see http://lkml.org/lkml/2007/10/15/228
>
> I am not sure I fully understand your point, can you try to explain?
I can try...
on x86 interrupts are accounted to guest time if they occur when PF_VCPU
is set... and this not a problem because x86 time accounting is not
really accurate (and already works like that).
So as s390 accounting is working differently, it seems normal to correct
the accounted value.
To be annoying, it should be clearer to write this like:
if ( (p->flags & PF_VCPU) &&
!(hardirq_count() - hardirq_offset) &&
!softirq_count() )
{
account_guest_time(p, cputime);
return;
}
as we have:
#define hardirq_count() (preempt_count() & HARDIRQ_MASK)
#define softirq_count() (preempt_count() & SOFTIRQ_MASK)
#define irq_count() (preempt_count() & (HARDIRQ_MASK |
SOFTIRQ_MASK))
and in account_system_time():
...
if (hardirq_count() - hardirq_offset)
cpustat->irq = cputime64_add(cpustat->irq, tmp);
else if (softirq_count())
cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
else if (p != rq->idle) {
...
So it is easier to understand we don't account this time to guest if we
have hard irq or soft irq
But I agree with your patch.
Laurent
> My patch deals with timer ticks (see hardirq_offset). So if a only a tick
> comes in after local_irq_enable the time is accounted to guest time as
> before.
> I made a test on x86_64 with burnP6 inside a kvm machine. top showed 100%
> guest time on an otherwise idle host. So the guest accounting itself did
> still work. I tried some disk and network stress on the host but I did not
> manage to bring hardirq+softirq time above 5%, guest time stayed above
> 90%. At least my simple testcase did not show a bias towards irq time.
>
> > Le jeudi 15 novembre 2007 à 15:10 +0100, Christian Borntraeger a écrit :
> > > Avi pointed out, that my first patch was broken, here is the 2nd try.
> > > I tested the patch on s390 with CONFIG_VIRT_CPU_ACCOUNTING and on x86_64.
> > > Seems to work.
> > >
> > > 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.
> > >
> > > Avi, Ingo, Laurent, feedback is welcome.
> > >
> > > CC: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
> > > CC: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
> > > CC: Laurent Vivier <Laurent.Vivier-6ktuUTfB/bM@public.gmane.org>
> > > Signed-off-by: Christian Borntraeger <borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> > > ---
> > > kernel/sched.c | 6 ++----
> > > 1 file changed, 2 insertions(+), 4 deletions(-)
> > >
> > > Index: kvm/kernel/sched.c
> > > ===================================================================
> > > --- kvm.orig/kernel/sched.c
> > > +++ kvm/kernel/sched.c
> > > @@ -3395,10 +3395,8 @@ void account_system_time(struct task_str
> > > struct rq *rq = this_rq();
> > > cputime64_t tmp;
> > >
> > > - if (p->flags & PF_VCPU) {
> > > - account_guest_time(p, cputime);
> > > - return;
> > > - }
> > > + if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0))
> > > + return account_guest_time(p, cputime);
> > >
> > > p->stime = cputime_add(p->stime, cputime);
--
------------- Laurent.Vivier-6ktuUTfB/bM@public.gmane.org --------------
"Any sufficiently advanced technology is
indistinguishable from magic." - Arthur C. Clarke
[-- Attachment #1.2: Ceci est une partie de message numériquement signée --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #3: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next prev parent reply other threads:[~2007-11-15 17:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 15:32 [PATCH] kvm: Fix accounting of interrupts during guest execution on s390 Christian Borntraeger
[not found] ` <200711141632.37004.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-14 15:36 ` Ingo Molnar
[not found] ` <20071114153651.GA3441-X9Un+BFzKDI@public.gmane.org>
2007-11-14 15:47 ` Christian Borntraeger
[not found] ` <200711141647.45810.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-14 16:04 ` Avi Kivity
[not found] ` <473B1C97.2010007-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-14 16:07 ` Christian Borntraeger
2007-11-15 14:10 ` [PATCH v2] " Christian Borntraeger
[not found] ` <200711151510.37076.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-15 14:18 ` Ingo Molnar
2007-11-15 14:23 ` Avi Kivity
[not found] ` <473C5652.9070706-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-15 14:38 ` Christian Borntraeger
[not found] ` <200711151538.16774.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-15 14:40 ` Avi Kivity
2007-11-15 15:24 ` Laurent Vivier
2007-11-15 15:56 ` Christian Borntraeger
[not found] ` <200711151656.44935.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-15 17:08 ` Laurent Vivier [this message]
2007-11-15 18:05 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1195146486.4704.60.camel@frecb07144 \
--to=laurent.vivier-6ktuutfb/bm@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox