From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] arm/arm64: KVM: Properly account for guest CPU time
Date: Tue, 2 Jun 2015 13:55:37 +0200 [thread overview]
Message-ID: <20150602115537.GA12347@cbox> (raw)
In-Reply-To: <20150602092759.GA7783@cbox>
[replying to myself]
On Tue, Jun 02, 2015 at 11:27:59AM +0200, Christoffer Dall wrote:
[..]
> > >
> > > If this patch is incorrect, then how does it work on x86, where
> > > handle_external_intr() is called (with a barrier in between) before
> > > kvm_guest_exit(), and where handle_external_intr() is simply
> > > local_irq_enable() on SVM and something more complicated on VMX ?
> > >
> > > Finally, how exactly is preemption latency added here? Won't IRQ
> > > processing run with higher priority than any task on your system, so the
> > > order of (1) process pending IRQs (2) call schedule if needed is still
> > > preserved here, but we call kvm_guest_exit() between (1) and (2) instead
> > > of before (1).
> >
> > I may be missing something, but on return from interrupt with preempt
> > disabled we can't take the need resched path. And need to return
> > to KVM no?
>
> preempt_enable() will call __preempt_schedule() and cause preemption
> there, so you're talking about adding these lines of latency:
>
> kvm_guest_exit();
> trace_kvm_exit(kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
>
> And these were called with interrupts disabled before, so I don't see
> the issue??
>
> However, your question is making me think whether we have a race in the
> current code on fully preemptible kernels, if we get preempted before
> calling kvm_timer_sync_hwstate() and kvm_vgic_sync_hwstate(), then we
> could potentially schedule another vcpu on this core and loose/corrupt
> state, can we not? We probably need to check for this in
> kvm_vcpu_load/kvm_vcpu_put. I need to think more about if this is a
> real issue or if I'm seeing ghosts.
>
I've thought about it and I don't think there's a race because those
functions don't access the hardware directly, but only manipulate
per-vcpu data structures.
-Christoffer
next prev parent reply other threads:[~2015-06-02 11:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 18:49 [PATCH v2] arm/arm64: KVM: Properly account for guest CPU time Christoffer Dall
2015-05-29 22:34 ` Mario Smarduch
2015-05-31 6:59 ` Christoffer Dall
2015-06-01 15:48 ` Mario Smarduch
2015-06-02 9:27 ` Christoffer Dall
2015-06-02 11:55 ` Christoffer Dall [this message]
2015-06-05 12:24 ` Mario Smarduch
2015-06-08 11:35 ` Christoffer Dall
2015-06-09 23:04 ` Mario Smarduch
2015-06-01 7:47 ` Christian Borntraeger
2015-06-01 9:08 ` Christoffer Dall
2015-06-01 9:21 ` Christian Borntraeger
2015-06-01 13:35 ` Christoffer Dall
2015-06-01 13:37 ` Christian Borntraeger
2015-06-02 9:28 ` Christoffer Dall
2015-06-01 11:34 ` Paolo Bonzini
2015-06-01 11:42 ` Christian Borntraeger
2015-06-01 11:52 ` Paolo Bonzini
2015-06-08 17:50 ` Marc Zyngier
2015-06-09 14:43 ` Christoffer Dall
2015-06-09 16:39 ` Marc Zyngier
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=20150602115537.GA12347@cbox \
--to=christoffer.dall@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).