From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>
Cc: linuxppc-dev@ozlabs.org, kvm@vger.kernel.org
Subject: Re: [PATCH 13/13] kvm/powerpc: Allow book3s_hv guests to use SMT processor modes
Date: Tue, 17 May 2011 20:44:22 +1000 [thread overview]
Message-ID: <20110517104422.GB7924@brick.ozlabs.ibm.com> (raw)
In-Reply-To: <F90D2118-7694-4AB0-9C17-8B449D14B9DF@suse.de>
On Tue, May 17, 2011 at 10:21:56AM +0200, Alexander Graf wrote:
>
> On 11.05.2011, at 12:46, Paul Mackerras wrote:
>
> > -#define KVM_MAX_VCPUS 1
> > +#define KVM_MAX_VCPUS NR_CPUS
> > +#define KVM_THREADS_PER_CORE 4
>
> So what if POWER8 (or whatever it will be called) comes along with 8
> threads per core? Would that change the userspace interface?
The idea is that userspace queries the KVM_CAP_PPC_SMT capability and
the value it gets back is the number of vcpus per vcore. It then
allocates vcpu numbers based on that.
If a CPU came along with more than 4 threads per core then we'd have
to change that define in the kernel, but that won't affect the
userspace API.
> > + /* wait for secondary threads to get back to nap mode */
> > + spin_lock(&vc->lock);
> > + if (vc->nap_count < vc->n_woken)
> > + kvmppc_wait_for_nap(vc);
>
> So you're taking the vcore wide lock and wait for other CPUs to set
> themselves to nap? Not sure I fully understand this. Why would
> another thread want to go to nap mode when it's 100% busy?
It's more about waiting for the other hardware threads to have
finished writing their vcpu state to memory. Currently those threads
then go to nap mode, but they could in fact poll instead for a bit,
so that name is possible a bit misleading, I agree.
> > + cmpwi r12,0x980
> > + beq 40f
> > + cmpwi r3,0x100
>
> good old use define comment :)
Yep, OK. :)
> Maybe I also missed the point here, but how does this correlate with
> Linux threads? Is each vcpu running in its own Linux thread? How
> does the scheduling happen? IIUC the host only sees a single thread
> per core and then distributes the vcpus to the respective host
> threads.
Each vcpu has its own Linux thread, but while the vcore is running,
all but one of them are sleeping. The thing is that since the host is
running with each core single-threaded, one Linux thread is enough to
run 4 vcpus. So when we decide we can run the vcore, the vcpu thread
that discovered that we can now run the vcore takes the responsibility
to run it. That involves sending an IPI to the other hardware threads
to wake them up and get them to each run a vcpu. Then the vcpu thread
that is running the vcore dives into the guest switch code itself. It
synchronizes with the other threads and does the partition switch, and
then they all enter the guest.
We thought about various schemes to cope with the hardware restriction
that all hardware threads in a core have to be in the same partition
(at least whenever the MMU is on). This is the least messy scheme we
could come up with. I'd be happy to discuss the alternatives if you
like.
Paul.
next prev parent reply other threads:[~2011-05-17 10:44 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 10:34 [PATCH 0/13] Hypervisor-mode KVM on POWER7 Paul Mackerras
2011-05-11 10:36 ` [PATCH 01/13] kvm/powerpc: Move fields between struct kvm_vcpu_arch and kvmppc_vcpu_book3s Paul Mackerras
2011-05-11 10:38 ` [PATCH 02/13] kvm/powerpc: Fix kvmppc_core_pending_dec Paul Mackerras
2011-05-11 10:39 ` [PATCH 03/13] kvm/powerpc: Fix the build for 32-bit Book 3S (classic) processors Paul Mackerras
2011-05-12 9:33 ` Alexander Graf
2011-05-12 11:15 ` Paul Mackerras
2011-05-12 11:16 ` Benjamin Herrenschmidt
2011-05-12 11:57 ` Alexander Graf
2011-05-11 10:40 ` [PATCH 04/13] kvm/powerpc: Split out code from book3s.c into book3s_pr.c Paul Mackerras
2011-05-11 10:41 ` [PATCH 05/13] powerpc, kvm: Rework KVM checks in first-level interrupt handlers Paul Mackerras
2011-05-11 10:42 ` [PATCH 06/13] kvm/powerpc: Deliver program interrupts right away instead of queueing them Paul Mackerras
2011-05-11 10:42 ` [PATCH 07/13] kvm/powerpc: Pass init/destroy vm and prepare/commit memory region ops down Paul Mackerras
2011-05-11 10:43 ` [PATCH 08/13] kvm/powerpc: Move guest enter/exit down into subarch-specific code Paul Mackerras
2011-05-17 18:05 ` Marcelo Tosatti
2011-05-17 18:10 ` Marcelo Tosatti
2011-05-11 10:44 ` [PATCH 09/13] powerpc: Set up LPCR for running guest partitions Paul Mackerras
2011-05-11 10:44 ` [PATCH 10/13] kvm/powerpc: Add support for Book3S processors in hypervisor mode Paul Mackerras
2011-05-12 9:07 ` Avi Kivity
2011-05-16 1:07 ` Paul Mackerras
2011-05-15 21:58 ` Alexander Graf
2011-05-16 5:58 ` Paul Mackerras
2011-05-17 10:17 ` Alexander Graf
2011-05-27 10:33 ` Paul Mackerras
2011-05-27 10:43 ` Alexander Graf
2011-05-27 20:59 ` Segher Boessenkool
2011-05-27 23:19 ` Alexander Graf
2011-05-28 1:07 ` Segher Boessenkool
2011-05-31 20:26 ` Jimi Xenidis
2011-05-31 22:34 ` Segher Boessenkool
2011-06-01 5:11 ` Paul Mackerras
2011-05-11 10:45 ` [PATCH 11/13] kvm/powerpc: Handle some PAPR hcalls in the kernel Paul Mackerras
2011-05-17 7:54 ` Alexander Graf
2011-05-17 10:28 ` Paul Mackerras
2011-05-11 10:46 ` [PATCH 12/13] kvm/powerpc: Accelerate H_PUT_TCE by implementing it in real mode Paul Mackerras
2011-05-17 8:01 ` Alexander Graf
2011-05-17 9:11 ` Benjamin Herrenschmidt
2011-05-17 9:31 ` Alexander Graf
2011-05-17 9:35 ` Benjamin Herrenschmidt
2011-05-17 9:39 ` Alexander Graf
2011-05-11 10:46 ` [PATCH 13/13] kvm/powerpc: Allow book3s_hv guests to use SMT processor modes Paul Mackerras
2011-05-11 13:44 ` Christoph Hellwig
2011-05-11 21:17 ` Paul Mackerras
2011-05-17 8:21 ` Alexander Graf
2011-05-17 10:44 ` Paul Mackerras [this message]
2011-05-17 11:36 ` Alexander Graf
2011-05-19 6:06 ` Paul Mackerras
2011-05-17 9:46 ` [PATCH 0/13] Hypervisor-mode KVM on POWER7 Alexander Graf
2011-05-17 11:15 ` Paul Mackerras
2011-05-17 11:38 ` Alexander Graf
2011-05-17 11:42 ` Avi Kivity
2011-05-19 5:22 ` Paul Mackerras
2011-05-19 6:01 ` Alexander Graf
2011-05-21 16:41 ` Alexander Graf
2011-05-21 17:00 ` Alexander Graf
2011-05-21 18:15 ` 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=20110517104422.GB7924@brick.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=agraf@suse.de \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.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).