From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Christoffer Dall <cdall@linaro.org>
Cc: Christoffer Dall <christoffer.dall@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Marc Zyngier <marc.zyngier@arm.com>,
Rik van Riel <riel@redhat.com>
Subject: Re: vtime accounting
Date: Tue, 14 Mar 2017 22:53:41 +0100 [thread overview]
Message-ID: <20170314215340.GE14790@potion> (raw)
In-Reply-To: <20170314202721.GD5432@potion>
2017-03-14 21:27+0100, Radim Krčmář:
> 2017-03-14 19:39+0100, Christoffer Dall:
>> On Tue, Mar 14, 2017 at 05:58:59PM +0100, Radim Krčmář wrote:
>>> 2017-03-14 09:26+0100, Christoffer Dall:
>>> > On Mon, Mar 13, 2017 at 06:28:16PM +0100, Radim Krčmář wrote:
>>> >> 2017-03-08 02:57-0800, Christoffer Dall:
>>> >> > Hi Paolo,
>>> >> >
>>> >> > I'm looking at improving KVM/ARM a bit by calling guest_exit_irqoff
>>> >> > before enabling interrupts when coming back from the guest.
>>> >> >
>>> >> > Unfortunately, this appears to mess up my view of CPU usage using
>>> >> > something like htop on the host, because it appears all time is spent
>>> >> > inside the kernel.
>>> >> >
>>> >> > From my analysis, I think this is because we never handle any interrupts
>>> >> > before enabling interrupts, where the x86 code does its
>>> >> > handle_external_intr, and the result on ARM is that we never increment
>>> >> > jiffies before doing the vtime accounting.
>>> >>
>>> >> (Hm, the counting might be broken on nohz_full then.)
>>> >>
>>> >
>>> > Don't you still have a scheduler tick even with nohz_full and something
>>> > that will eventually update jiffies then?
>>>
>>> Probably, I don't understand jiffies accounting too well and didn't see
>>> anything that would bump the jiffies in or before guest_exit_irqoff().
>>
>> As far as I understand, from my very very short time of looking at the
>> timer code, jiffies are updated on every tick, which can be cause by a
>> number of events, including *any* interrupt handler (coming from idle
>> state), soft timers, timer interrupts, and possibly other things.
>
> Yes, I was thinking that entering/exiting user mode should trigger it as
> well, in order to correctly account for time spent there, but couldn't
> find it ...
>
> The case I was wondering about is if the kernel spent e.g. 10 jiffies in
> guest mode and then exited on mmio -- no interrupt in the host, and
> guest_exit_irqoff() would flip accouting would over system time.
> Can those 10 jiffies get accounted to system (not guest) time?
>
> Accounting 1 jiffy wrong is normal as we expect that the distribution of
> guest/kernel time in the jiffy is going to be approximated over a longer
> sampling period, but if we could account multiple jiffies wrong, this
> expectation is very hard to defend.
IIUC, other CPU will bump jiffies of running tickless VCPUs, so this
works fine.
next prev parent reply other threads:[~2017-03-14 21:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 10:57 vtime accounting Christoffer Dall
2017-03-09 8:16 ` Paolo Bonzini
2017-03-13 17:28 ` Radim Krčmář
2017-03-14 8:26 ` Christoffer Dall
2017-03-14 8:55 ` Marc Zyngier
2017-03-14 11:12 ` Christoffer Dall
2017-03-14 11:46 ` Marc Zyngier
2017-03-14 16:58 ` Radim Krčmář
2017-03-14 17:09 ` Paolo Bonzini
2017-03-14 18:41 ` Christoffer Dall
2017-03-14 19:32 ` Radim Krčmář
2017-03-14 20:01 ` Christoffer Dall
2017-03-14 21:52 ` Radim Krčmář
2017-03-15 8:09 ` Paolo Bonzini
2017-03-15 8:05 ` Paolo Bonzini
2017-03-15 8:30 ` Christoffer Dall
2017-03-14 18:39 ` Christoffer Dall
2017-03-14 20:27 ` Radim Krčmář
2017-03-14 21:53 ` Radim Krčmář [this message]
2017-03-15 8:43 ` Christoffer Dall
2017-03-15 15:57 ` Radim Krčmář
2017-03-15 16:48 ` Christoffer Dall
2017-03-15 17:09 ` Radim Krčmář
2017-03-24 15:04 ` Rik van Riel
2017-03-27 12:29 ` Wanpeng Li
2017-03-24 14:55 ` Rik van Riel
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=20170314215340.GE14790@potion \
--to=rkrcmar@redhat.com \
--cc=cdall@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
--cc=riel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.