From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
KVM <kvm@vger.kernel.org>, qemu-devel <qemu-devel@nongnu.org>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
linux-s390 <linux-s390@vger.kernel.org>
Subject: Re: [Qemu-devel] [PATCH/RFC 4/5] s390x/kvm: test whether a cpu is STOPPED when checking "has_work"
Date: Thu, 31 Jul 2014 09:45:01 +0200 [thread overview]
Message-ID: <20140731094501.31d8a047@thinkpad-w530> (raw)
In-Reply-To: <53D78A44.1060706@suse.de>
> > We have
> > - wait (wait bit in PSW)
> > - disabled wait (wait bit and interrupt fencing in PSW)
> > - STOPPED (not related to PSW, state change usually handled via service processor or hypervisor)
> >
> > I think we have to differentiate between KVM/TCG. On KVM we always do in kernel halt and qemu sees a halted only for STOPPED or disabled wait. TCG has to take care of the normal wait as well.
> >
> > From a first glimpse, a disabled wait and STOPPED look similar, but there are (important) differences, e.g. other CPUs get a different a different result from a SIGP SENSE. This makes a big difference, e.g. for Linux guests, that send a SIGP STOP, followed by a SIGP SENSE loop until the CPU is down on hotplug (and shutdown, kexec..) So I think we agree, that handling the cpu states natively makes sense.
> >
> > The question is now only how to model it correctly without breaking TCG/KVM and reuse as much common code as possible. Correct?
> >
> > Do I understand you correctly, that your collapsing of stopped and halted is only in the qemu coding sense, IOW maybe we could just modify kvm_arch_process_async_events to consider the STOPPED state, as TCGs sigp implementation does not support SMP anyway?
>
> That works for me, yes.
>
>
> Alex
>
I had a look at it yesterday and it seems like we can totally drop this patch:
1. TCG doesn't support multiple CPUs and the TCG SIGP implementation isn't
ready for proper STOP/START/SENSE. Testing for STOPPED cpus in cpu_has_work()
can be dropped. To be able to support TCG was the main reason for this patch -
as we don't want to do so for now, we can leave it as is. We can still decide
to support the cpu states later using a mechanism suggest by Alex
(interrupt_requests).
Even if cpu_has_work() would make cpu.c:cpu_thread_is_idle() return false,
kvm_arch_process_async_events() called by kvm-all.c:kvm_cpu_exec() would make
it go back to sleep. Therefore a stopped VCPU will never be able to run in the
KVM case (because it always has cs->halted = true).
2. The unhalt in kvm_arch_process_async_events is for a special case where a
VCPU is in disabled wait and receives e.g. a machine-check interrupt. These
might happen in the future, for now we will never see them (the only
way to get a vcpu out of disabled wait are SIGP RESTART/CPU RESET - so we
don't break anything at that point).
David
WARNING: multiple messages have this Message-ID (diff)
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: linux-s390 <linux-s390@vger.kernel.org>,
KVM <kvm@vger.kernel.org>, qemu-devel <qemu-devel@nongnu.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH/RFC 4/5] s390x/kvm: test whether a cpu is STOPPED when checking "has_work"
Date: Thu, 31 Jul 2014 09:45:01 +0200 [thread overview]
Message-ID: <20140731094501.31d8a047@thinkpad-w530> (raw)
In-Reply-To: <53D78A44.1060706@suse.de>
> > We have
> > - wait (wait bit in PSW)
> > - disabled wait (wait bit and interrupt fencing in PSW)
> > - STOPPED (not related to PSW, state change usually handled via service processor or hypervisor)
> >
> > I think we have to differentiate between KVM/TCG. On KVM we always do in kernel halt and qemu sees a halted only for STOPPED or disabled wait. TCG has to take care of the normal wait as well.
> >
> > From a first glimpse, a disabled wait and STOPPED look similar, but there are (important) differences, e.g. other CPUs get a different a different result from a SIGP SENSE. This makes a big difference, e.g. for Linux guests, that send a SIGP STOP, followed by a SIGP SENSE loop until the CPU is down on hotplug (and shutdown, kexec..) So I think we agree, that handling the cpu states natively makes sense.
> >
> > The question is now only how to model it correctly without breaking TCG/KVM and reuse as much common code as possible. Correct?
> >
> > Do I understand you correctly, that your collapsing of stopped and halted is only in the qemu coding sense, IOW maybe we could just modify kvm_arch_process_async_events to consider the STOPPED state, as TCGs sigp implementation does not support SMP anyway?
>
> That works for me, yes.
>
>
> Alex
>
I had a look at it yesterday and it seems like we can totally drop this patch:
1. TCG doesn't support multiple CPUs and the TCG SIGP implementation isn't
ready for proper STOP/START/SENSE. Testing for STOPPED cpus in cpu_has_work()
can be dropped. To be able to support TCG was the main reason for this patch -
as we don't want to do so for now, we can leave it as is. We can still decide
to support the cpu states later using a mechanism suggest by Alex
(interrupt_requests).
Even if cpu_has_work() would make cpu.c:cpu_thread_is_idle() return false,
kvm_arch_process_async_events() called by kvm-all.c:kvm_cpu_exec() would make
it go back to sleep. Therefore a stopped VCPU will never be able to run in the
KVM case (because it always has cs->halted = true).
2. The unhalt in kvm_arch_process_async_events is for a special case where a
VCPU is in disabled wait and receives e.g. a machine-check interrupt. These
might happen in the future, for now we will never see them (the only
way to get a vcpu out of disabled wait are SIGP RESTART/CPU RESET - so we
don't break anything at that point).
David
next prev parent reply other threads:[~2014-07-31 7:45 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-10 13:10 [PATCH/RFC 0/5] s390x/kvm: track the logical cpu state in QEMU and propagate it to kvm Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-10 13:10 ` [PATCH/RFC 1/5] update linux headers with with cpustate changes Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-10 13:10 ` [PATCH/RFC 2/5] s390x/kvm: introduce proper states for s390 cpus Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-10 13:10 ` [PATCH/RFC 3/5] s390x/kvm: proper use of the cpu states OPERATING and STOPPED Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-10 13:10 ` [PATCH/RFC 4/5] s390x/kvm: test whether a cpu is STOPPED when checking "has_work" Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-28 13:49 ` Alexander Graf
2014-07-28 13:49 ` [Qemu-devel] " Alexander Graf
2014-07-28 14:16 ` David Hildenbrand
2014-07-28 14:16 ` David Hildenbrand
2014-07-28 14:19 ` Paolo Bonzini
2014-07-28 14:19 ` Paolo Bonzini
2014-07-28 14:22 ` Alexander Graf
2014-07-28 14:22 ` Alexander Graf
2014-07-28 15:03 ` David Hildenbrand
2014-07-28 15:03 ` David Hildenbrand
2014-07-28 15:57 ` David Hildenbrand
2014-07-28 15:57 ` David Hildenbrand
2014-07-28 16:45 ` Alexander Graf
2014-07-28 16:45 ` Alexander Graf
2014-07-29 13:52 ` Paolo Bonzini
2014-07-29 13:52 ` Paolo Bonzini
2014-07-29 15:06 ` David Hildenbrand
2014-07-29 15:06 ` David Hildenbrand
2014-07-29 11:44 ` Christian Borntraeger
2014-07-29 11:44 ` Christian Borntraeger
2014-07-29 11:44 ` Christian Borntraeger
2014-07-29 11:49 ` Alexander Graf
2014-07-29 11:49 ` Alexander Graf
2014-07-31 7:45 ` David Hildenbrand [this message]
2014-07-31 7:45 ` David Hildenbrand
2014-07-10 13:10 ` [PATCH/RFC 5/5] s390x/kvm: propagate s390 cpu state to kvm Christian Borntraeger
2014-07-10 13:10 ` [Qemu-devel] " Christian Borntraeger
2014-07-10 13:14 ` [PATCH/RFC 0/5] s390x/kvm: track the logical cpu state in QEMU and propagate it " David Hildenbrand
2014-07-10 13:14 ` [Qemu-devel] " David Hildenbrand
2014-07-10 13:14 ` David Hildenbrand
2014-07-10 13:14 ` [Qemu-devel] " David Hildenbrand
2014-07-10 13:27 ` David Hildenbrand
2014-07-10 13:27 ` [Qemu-devel] " David Hildenbrand
2014-07-28 13:43 ` Alexander Graf
2014-07-28 13:43 ` [Qemu-devel] " Alexander Graf
2014-07-28 13:45 ` Alexander Graf
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=20140731094501.31d8a047@thinkpad-w530 \
--to=dahi@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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 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.