From patchwork Fri Sep 30 03:22:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9357601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 795B7600C8 for ; Fri, 30 Sep 2016 03:23:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66B1E29D8B for ; Fri, 30 Sep 2016 03:23:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A98B29D8D; Fri, 30 Sep 2016 03:23:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED7E029D8B for ; Fri, 30 Sep 2016 03:23:17 +0000 (UTC) Received: from localhost ([::1]:41585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpoPs-0003kv-Qb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Sep 2016 23:23:16 -0400 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 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 30 Sep 2016 13:22:43 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 4B6F92BB0059; Fri, 30 Sep 2016 13:22:43 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8U3MhI144826804; Fri, 30 Sep 2016 13:22:43 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8U3MguZ015619; Fri, 30 Sep 2016 13:22:43 +1000 Received: from in.ibm.com ([9.84.216.171]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u8U3McEn015503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Sep 2016 13:22:41 +1000 Date: Fri, 30 Sep 2016 08:52:37 +0530 From: Bharata B Rao To: David Gibson References: <1474433280-25652-1-git-send-email-bharata@linux.vnet.ibm.com> <20160921053100.GZ20488@umbus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160921053100.GZ20488@umbus> User-Agent: Mutt/1.6.1 (2016-04-27) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16093003-0004-0000-0000-000001A0BD07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16093003-0005-0000-0000-000008CA07ED Message-Id: <20160930032237.GA3812@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-30_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609280000 definitions=main-1609300059 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: Re: [Qemu-devel] [RFC PATCH v0] spapr: Disable CPU unplug in TCG mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: bharata@linux.vnet.ibm.com Cc: alex.bennee@linaro.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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. 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