From: Scott Wood <scottwood@freescale.com>
To: Alexander Graf <agraf@suse.de>
Cc: Bharat Bhushan <r65777@freescale.com>, <kvm-ppc@vger.kernel.org>,
<kvm@vger.kernel.org>, <bharatb.yadav@gmail.com>,
Bharat Bhushan <Bharat.Bhushan@freescale.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Kumar Gala <galak@kernel.crashing.org>
Subject: Re: [PATCH 2/2 v2] KVM: PPC: booke: Add watchdog emulation
Date: Mon, 16 Jul 2012 20:02:13 -0500 [thread overview]
Message-ID: <5004B995.8060303@freescale.com> (raw)
In-Reply-To: <50044CF1.8070806@suse.de>
On 07/16/2012 12:18 PM, Alexander Graf wrote:
>> +/*
>> + * Return the number of jiffies until the next timeout. If the
> timeout is
>> + * longer than the NEXT_TIMER_MAX_DELTA, that
>
> then?
>
>> return NEXT_TIMER_MAX_DELTA
>> + * instead.
>
> I can read code.
Come on, it's not exactly x++; /* add one to x */
It's faster to read code (as well as know the constraints within which
you can modify it without having to spend a lot of time digesting all
the callers' use cases) when you have a high level description of its
interface contract, and can be selective about when to zoom in to the
details. Linux kernel code tends to be bad about this.
> The important piece of information in the comment is
> missing: The reason.
The reason for what? Why you want to know the next timeout? That's the
caller's business. Or why we use NEXT_TIMER_MAX_DELTA as the limit?
>> +void kvmppc_watchdog_func(unsigned long data)
>> +{
>> + struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
>> + u32 tsr, new_tsr;
>> + int final;
>> +
>> + do {
>> + new_tsr = tsr = vcpu->arch.tsr;
>> + final = 0;
>> +
>> + /* Time out event */
>> + if (tsr & TSR_ENW) {
>> + if (tsr & TSR_WIS) {
>> + new_tsr = (tsr & ~TCR_WRC_MASK) |
>> + (vcpu->arch.tcr & TCR_WRC_MASK);
>> + vcpu->arch.tcr &= ~TCR_WRC_MASK;
>
> Can't we just poke the vcpu to exit the VM and do the above on its own?
We've discussed this before. TSR updates are done via atomics, and we
send a request for the vcpu to act on the result. This is how the
decrementer works.
http://www.spinics.net/lists/kvm-ppc/msg03169.html
> This is the watdog expired case, right?
Final expiration, yes.
> I'd also prefer to have an
> explicit event for the expiry than a special TSR check in the main loop.
So check TSR[WRS] in update_timer_ints(), and have it queue a
pseudoexception? That would eliminate the need to change the runnable
function.
> Also call me sceptic on the reset of tcr. If our user space watchdog
> event is "write a message", then we essentially want to hide the fact
> that the watchdog expired from the guest, right? In that case, the
> second time-out wouldn't do anything guest visible.
This was probably copied straight out of the hardware documentation,
which explicitly says TCR[WRC] gets set to zero on final expiration (as
part of reset). We should leave that part up to userspace. It
definitely shouldn't be done inside the cmpxchg loop (or from interrupt
context -- only TSR gets the atomic treatment). I don't think the read
of TCR outside vcpu context is a problem, though.
>> int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
>> {
>> - return !(v->arch.shared->msr & MSR_WE) ||
>> - !!(v->arch.pending_exceptions) ||
>> - v->requests;
>> + bool ret = !(v->arch.shared->msr & MSR_WE) ||
>> + !!(v->arch.pending_exceptions) ||
>> + v->requests;
>> +
>> + ret = ret || kvmppc_get_tsr_wrc(v);
>
> Why do you need to declare the cpu as non-runnable when a watchdog event
> occured?
It's the other way around -- it's always runnable when a watchdog exit
is pending. It's like a pending exception.
>> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
>> index 2ce09aa..b9fdb52 100644
>> --- a/include/linux/kvm.h
>> +++ b/include/linux/kvm.h
>> @@ -163,6 +163,7 @@ struct kvm_pit_config {
>> #define KVM_EXIT_OSI 18
>> #define KVM_EXIT_PAPR_HCALL 19
>> #define KVM_EXIT_S390_UCONTROL 20
>> +#define KVM_EXIT_WDT 21
>
> Please make this a more generic KVM_EXIT_WATCHDOG so that other archs
> may have the chance to reuse it.
WDT is generic (85 of 115 files in drivers/watchdog/ contain "wdt" in
their names), just overly abbreviated. KVM_EXIT_WATCHDOG is more readable.
-Scott
next prev parent reply other threads:[~2012-07-17 1:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-09 10:34 [PATCH 2/2 v2] KVM: PPC: booke: Add watchdog emulation Bharat Bhushan
2012-07-16 17:18 ` Alexander Graf
2012-07-17 1:02 ` Scott Wood [this message]
2012-07-17 7:20 ` Alexander Graf
2012-07-17 9:57 ` Bhushan Bharat-R65777
2012-07-17 12:51 ` Alexander Graf
2012-07-17 13:15 ` Bhushan Bharat-R65777
2012-07-17 14:01 ` Alexander Graf
2012-07-17 14:13 ` Bhushan Bharat-R65777
2012-07-17 14:35 ` Alexander Graf
2012-07-17 16:10 ` Bhushan Bharat-R65777
2012-07-17 16:27 ` Scott Wood
2012-07-17 16:51 ` Alexander Graf
2012-07-17 18:00 ` Scott Wood
2012-07-17 11:31 ` Bhushan Bharat-R65777
2012-07-17 16:37 ` Scott Wood
2012-07-17 16:56 ` Bhushan Bharat-R65777
2012-07-17 17:00 ` Scott Wood
2012-07-17 17:10 ` Bhushan Bharat-R65777
2012-07-17 17:25 ` Scott Wood
2012-07-17 17:29 ` Bhushan Bharat-R65777
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=5004B995.8060303@freescale.com \
--to=scottwood@freescale.com \
--cc=Bharat.Bhushan@freescale.com \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=bharatb.yadav@gmail.com \
--cc=galak@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=r65777@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox