From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH v3 18/18] xen/arm: IRQ: Handle multiple action per IRQ Date: Thu, 17 Apr 2014 11:36:54 +0100 Message-ID: <534FAEC6.9070303@linaro.org> References: <1396968247-8768-1-git-send-email-julien.grall@linaro.org> <1396968247-8768-19-git-send-email-julien.grall@linaro.org> <1397663693.24638.226.camel@kazak.uk.xensource.com> <534EAA6C.9070601@linaro.org> <1397665048.24638.237.camel@kazak.uk.xensource.com> <534EAE7C.7090609@linaro.org> <534F99C90200007800009DAE@nat28.tlf.novell.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 1Wajgf-0004DA-VZ for xen-devel@lists.xenproject.org; Thu, 17 Apr 2014 10:36:58 +0000 Received: by mail-ee0-f45.google.com with SMTP id d17so498223eek.32 for ; Thu, 17 Apr 2014 03:36:56 -0700 (PDT) In-Reply-To: <534F99C90200007800009DAE@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel@lists.xenproject.org, Keir Fraser , stefano.stabellini@citrix.com, Ian Campbell , tim@xen.org List-Id: xen-devel@lists.xenproject.org On 04/17/2014 08:07 AM, Jan Beulich wrote: >>>> On 16.04.14 at 18:23, wrote: >> On 04/16/2014 05:17 PM, Ian Campbell wrote: >>> On Wed, 2014-04-16 at 17:06 +0100, Julien Grall wrote: >>>> On 04/16/2014 04:54 PM, Ian Campbell wrote: >>>>> On Tue, 2014-04-08 at 15:44 +0100, Julien Grall wrote: >>>>>> desc->status &= ~IRQ_PENDING; >>>>>> spin_unlock_irq(&desc->lock); >>>>>> - action->handler(irq, action->dev_id, regs); >>>>>> + list_for_each_entry_safe(action, next, &desc->action, next) >>>>>> + action->handler(irq, action->dev_id, regs); >>>>> >>>>> You aren't removing entries from within the loop so I don't think you >>>>> need the _safe variant. >>>> >>>> As we release the desc->lock here, it might be possible to have the list >>>> changed under the CPU feet by release_irq. >>>> >>>> With the double-linked list, how do we make sure that it won't happen? >>> >>> Normally by using a lock. I don't know if even list_for_each_entry_safe >>> is safe against concurrent changes to the list from other threads, I >>> think it only refers to safe to changing the list within the loop in >>> this thread. >>> >> >> Hmmmm... I'm wondering if we can keep desc->lock held while calling the >> action handler and enable IRQ. > > That would set you up for problems with the handler wanting to > manipulate its IRQ (which might imply locking desc). I'd suggest > looking at how Linux deals with this (synchronize_irq() in particular). The release_irq code is borrowed from Linux. We already synchronize at the end. We have to delete the element in the critical section to avoid race with adding a new element. synchronizing in the critical section is not possible because do_IRQ will have to take the lock to clear the IRQ_INPROGRESS flag. In Linux case, they are safe because they are using a single linked list. -- Julien Grall