From: "Jan Beulich" Subject: Re: [PATCH] dpci: Put the dpci back on the list if scheduled from another CPU. Date: Wed, 18 Mar 2015 07:38:12 +0000 Message-ID: <55093974020000780006B1CF@mail.emea.novell.com> References: <1426606715-18018-1-git-send-email-konrad.wilk@oracle.com> <55085F06020000780006B053@mail.emea.novell.com> <20150317171537.GA4101@l.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YY8YR-00065l-Jl for xen-devel@lists.xenproject.org; Wed, 18 Mar 2015 07:38:15 +0000 In-Reply-To: <20150317171537.GA4101@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: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 17.03.15 at 18:15, wrote: > On Tue, Mar 17, 2015 at 04:06:14PM +0000, Jan Beulich wrote: >> >>> On 17.03.15 at 16:38, 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)); >> > + local_irq_restore(flags); >> > + >> > + raise_softirq(HVM_DPCI_SOFTIRQ); >> > + continue; >> > + } >> >> As just said in another mail - unless there are convincing new >> arguments in favor of this (more of a hack than a real fix), I'm >> not going to accept it and instead consider reverting the >> offending commit. Iirc the latest we had come to looked quite a >> bit better than this one. > > The latest one (please see attached) would cause an dead-lock iff > on the CPU we are running the softirq and an do_IRQ comes for the > exact dpci we are in process of executing. I'm afraid I'm not seeing it - please explain. As to the code - I think switch() is rather hiding the intentions here, i.e. the code would be better readable if using two if()s: + for ( ;; ) + { + old = cmpxchg(&pirq_dpci->state, 0, 1 << STATE_SCHED); + /* If the 'state' is 0 (not in use) we can schedule it. */ + if ( !old ) + break; + if ( !(old & (1 << STATE_RUN)) ) + { + /* Whenever STATE_SCHED is set we MUST not schedule it. */ + assert(old & (1 << STATE_SCHED)); + return; + } + } Jan