From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpoPY-0003kd-6V for qemu-devel@nongnu.org; Thu, 29 Sep 2016 23:22:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpoPT-0001gY-3Q for qemu-devel@nongnu.org; Thu, 29 Sep 2016 23:22:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58017 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpoPS-0001gM-Um for qemu-devel@nongnu.org; Thu, 29 Sep 2016 23:22:51 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8U3HjUV112333 for ; Thu, 29 Sep 2016 23:22:50 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0b-001b2d01.pphosted.com with ESMTP id 25s8t9fvpa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 29 Sep 2016 23:22:49 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Sep 2016 13:22:47 +1000 Date: Fri, 30 Sep 2016 08:52:37 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <1474433280-25652-1-git-send-email-bharata@linux.vnet.ibm.com> <20160921053100.GZ20488@umbus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160921053100.GZ20488@umbus> Message-Id: <20160930032237.GA3812@in.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, alex.bennee@linaro.org 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.