From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, alex.bennee@linaro.org
Subject: Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode
Date: Fri, 30 Sep 2016 08:52:37 +0530 [thread overview]
Message-ID: <20160930032237.GA3812@in.ibm.com> (raw)
In-Reply-To: <20160921053100.GZ20488@umbus>
On Wed, Sep 21, 2016 at 03:31:00PM +1000, David Gibson wrote:
> On Wed, Sep 21, 2016 at 10:18:00AM +0530, Bharata B Rao wrote:
> > CPU unplug doesn't work in TCG mode currently and causes frequent system
> > freeze. In addition to other potential problems, the main problem arises
> > of out the requirement to support synchronous removal of a CPU thread.
> > The CPU thread that performs the cleanup of the unplugged CPU, kicks and
> > waits for the unplugged CPU thread to finish. This wait never finishes in
> > TCG mode when the waiting thread and the unplugged CPU thread are one and
> > the same.
> >
> > So wait till proper MTTCG support is available before enabling
> > CPU unplug in TCG mode.
>
> MTTCG seems like a very big hammer to fix this with. Surely we could
> come up with a simpler interlock that would work for TCG in the
> meantime.
The following hack fixes the issue mostly. I still see some occasional
hangs which points to other potential problems.
diff --git a/cpus.c b/cpus.c
index 8ad1eb4..7dc7d09 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1526,8 +1526,13 @@ void cpu_remove(CPUState *cpu)
void cpu_remove_sync(CPUState *cpu)
{
cpu_remove(cpu);
- while (cpu->created) {
- qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+ if (!kvm_enabled()) {
+ qemu_tcg_destroy_vcpu(cpu);
+ cpu->created = false;
+ } else {
+ while (cpu->created) {
+ qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
+ }
}
}
@@ -1573,6 +1578,9 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
/* For non-MTTCG cases we share the thread */
cpu->thread = single_tcg_cpu_thread;
cpu->halt_cond = single_tcg_halt_cond;
+ cpu->thread_id = first_cpu->thread_id;
+ cpu->created = true;
+ cpu->can_do_io = 1;
}
}
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index dc058e5..9558fc9 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -244,6 +244,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
CPUPPCState *env = &cpu->env;
cs->halted = 1;
+ cs->stop = true;
qemu_cpu_kick(cs);
/*
* While stopping a CPU, the guest calls H_CPPR which
This is however on Alex's MTTCG tree, I need to figure out which are
the fixes that are relavent from Alex's tree to get CPU unplug working
in TCG mode.
Regards,
Bharata.
prev parent reply other threads:[~2016-09-30 3:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-21 4:48 [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode Bharata B Rao
2016-09-21 5:02 ` no-reply
2016-09-21 5:05 ` Fam Zheng
2016-09-21 5:31 ` David Gibson
2016-09-30 3:22 ` Bharata B Rao [this message]
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=20160930032237.GA3812@in.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=alex.bennee@linaro.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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.