From patchwork Fri Jul 15 11:52:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9231809 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 9DBFB60574 for ; Fri, 15 Jul 2016 11:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84C3C2832D for ; Fri, 15 Jul 2016 11:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 780502832F; Fri, 15 Jul 2016 11:56:47 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFB662832D for ; Fri, 15 Jul 2016 11:56:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bO1gb-0000bU-On; Fri, 15 Jul 2016 11:53:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bO1ga-0000af-Rq for xen-devel@lists.xenproject.org; Fri, 15 Jul 2016 11:53:40 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id C3/04-12285-4CEC8875; Fri, 15 Jul 2016 11:53:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRWlGSWpSXmKPExsXitHRDpO7hcx3 hBkuvy1l83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkf139mKzinUNHddIS9gfGSTBcjJ4eEQIhE 4/9LrCA2r4CRxKzfzWwgtrBAtMSb+5MYQWw2AQOJNzv2gtWICLhKXL99B8jm4GAWqJF4/1oAJ MwioCrxaPU3RpAwp4CGxLoTml2MXBxCAh8YJZ5tPsEMUsMvIClx68tHMJtZoFqiZ9JbNogT9C WOz1vBBnGCoMTJmU9YQGwhATWJGXMvs0LUcEvcPj2VeQIj/ywk7bOQtEDENSVat/9mh7C1JZY tfM0MYdtKrFv3HqrGRmLT1QWMELa8xPa3c5gXMLKvYtQoTi0qSy3SNTLTSyrKTM8oyU3MzNE1 NDDVy00tLk5MT81JTCrWS87P3cQIDPF6BgbGHYy3J/sdYpTkYFIS5d2Y0hEuxJeUn1KZkVicE V9UmpNafIhRhoNDSYL31RmgnGBRanpqRVpmDjDaYNISHDxKIrwJZ4HSvMUFibnFmekQqVOMuh xbFtxYyyTEkpeflyolzusEUiQAUpRRmgc3Ahb5lxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCo J8+qATOHJzCuB2/QK6AgmoCOszdtBjihJREhJNTAKnfp8+sbrB8oLuP1fMjo9WD7lxbo9sTad AQ9avr+uZz8dvG/p039ioetd/obZzRCQfqWpZBddwtLXy7B6yU3JRaWrX8vFlIhO5A680vbtl 7RB9sE91iIVFzZYH5SPU5tSGrTz0tFNcY8u/pxz7HuQQ9O2TydXFpvFz4q/buBXbPlmwzxPzo cGSizFGYmGWsxFxYkAEkjsjvcCAAA= X-Env-Sender: prvs=997f69562=dario.faggioli@citrix.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1468583617!49892763!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50169 invoked from network); 15 Jul 2016 11:53:39 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 15 Jul 2016 11:53:39 -0000 X-IronPort-AV: E=Sophos;i="5.28,368,1464652800"; d="asc'?scan'208";a="366430826" Message-ID: <1468583562.13039.96.camel@citrix.com> From: Dario Faggioli To: Juergen Gross , Date: Fri, 15 Jul 2016 13:52:42 +0200 In-Reply-To: <5788BCA2.4020404@suse.com> References: <146851288308.22413.4619190133086534604.stgit@Solace.fritz.box> <146851308019.22413.8905002507733716302.stgit@Solace.fritz.box> <5788AF33.2030603@suse.com> <1468577660.13039.78.camel@citrix.com> <5788BCA2.4020404@suse.com> Organization: Citrix Inc. X-Mailer: Evolution 3.18.5.2 (3.18.5.2-1.fc23) MIME-Version: 1.0 X-DLP: MIA2 Cc: George Dunlap , Andrew Cooper , Jan Beulich Subject: Re: [Xen-devel] [PATCH v2 1/2] xen: fix a (latent) cpupool-related race during domain destroy X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2016-07-15 at 12:36 +0200, Juergen Gross wrote: > On 15/07/16 12:14, Dario Faggioli wrote: > > In particular, I'm probably not fully understanding, from that > > commit > > changelog, what is the set of operations/command that I should run > > to > > check whether or not I reintroduced the issue back. > You need to create a domain in a cpupool and destroy it again while > some dom0 process still is holding a reference to it (resulting in a > zombie domain). Then try to destroy the cpupool. > Ah, I see. I wasn't get the fact that it needed to be a zombie domain from anywhere. > > What am I missing? > The domain being a zombie domain might change the picture. Moving it > to > cpupool0 was failing before my patch and it might do so again with > your > patch applied. > Mmmm... I don't immediately see the reason why moving a zombie domain fails either, but I guess I'll have to try. But then, correct me if I'm wrong, the situation is like this:  - right now there's a (potential) race between domain's scheduling     data destruction and domain removal from a cpupool;  - with my patch, the race goes away, but we risk not being able to     destroy a cpupool with a zombie domain in it. I don't think we want to be in either of these two situations. :-( The race is never triggering so far, but I've already patches to Credit2 (finishing implementing soft affinity for it) that make it a real thing. I think I can work around that specific case by doing something like the below: But even if that would be acceptable (what do you think?), I still don't like to have the race there lurking. :-/ Therefore, I still think this patch is correct, but I'm up for investigating further and finding a way to solve the "zombie in cpupool" issue as well. Regards, Dario Acked-by: Juergen Gross Acked-by: George Dunlap diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index bc0e794..d91fd70 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -193,12 +193,9 @@ struct cpupool    static inline cpumask_t* cpupool_domain_cpumask(struct domain *d)  { -    /* -     * d->cpupool is NULL only for the idle domain, and no one should -     * be interested in calling this for the idle domain. -     */ -    ASSERT(d->cpupool != NULL); -    return d->cpupool->cpu_valid; +    /* No one should be interested in calling this for the idle domain! */ +    ASSERT(!is_idle_domain(d)); +    return d->cpupool ? d->cpupool->cpu_valid : cpupool0->cpu_valid;  }    #endif /* __XEN_SCHED_IF_H__ */