From: "Jan Beulich" Subject: Re: [RFC PATCH] dpci: Put the dpci back on the list if running on another CPU. Date: Tue, 13 Jan 2015 10:26:08 +0000 Message-ID: <54B500D00200007800054386@mail.emea.novell.com> References: <1421081130-22959-1-git-send-email-konrad.wilk@oracle.com> <20150112173536.GA24188@l.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YAyfv-0002gy-2x for xen-devel@lists.xenproject.org; Tue, 13 Jan 2015 10:26:15 +0000 In-Reply-To: <20150112173536.GA24188@l.oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: andrew.cooper3@citrix.com, malcolm.crossley@citrix.com, xen-devel@lists.xenproject.org, linux@eikelenboom.it List-Id: xen-devel@lists.xenproject.org >>> On 12.01.15 at 18:35, wrote: >> --- a/xen/drivers/passthrough/io.c >> +++ b/xen/drivers/passthrough/io.c >> @@ -804,7 +804,17 @@ static void dpci_softirq(void) >> d = pirq_dpci->dom; >> smp_mb(); /* 'd' MUST be saved before we set/clear the bits. */ >> if ( test_and_set_bit(STATE_RUN, &pirq_dpci->state) ) >> - BUG(); >> + { >> + unsigned long flags; >> + >> + /* Put back on the list and retry. */ >> + local_irq_save(flags); >> + list_add_tail(&pirq_dpci->softirq_list, &this_cpu(dpci_list)); > > I chatted with Jan on IRC this, and one worry is that if we add > on our per-cpu list an 'dpci' that is running on another CPU - if > the other CPU runs 'list_del' it will go BOOM. Looking at this again, I don't think this particular case is a concern: The list_del() happens before setting STATE_RUN and clearing STATE_SCHED, and the race window only opens (and the potential list_add() can only happen) after this CPU cleared STATE_SCHED. Jan