WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 12/14] xen: events: remove use of nr_irqs as uppe

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 12/14] xen: events: remove use of nr_irqs as upper bound on number of pirqs
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Thu, 10 Mar 2011 08:57:36 +0000
Cc: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Thu, 10 Mar 2011 00:58:52 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20110310053305.GD10574@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <1299692459.17339.700.camel@xxxxxxxxxxxxxxxxxxxxxx> <1299692486-28634-12-git-send-email-ian.campbell@xxxxxxxxxx> <20110310053305.GD10574@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-03-10 at 05:33 +0000, Konrad Rzeszutek Wilk wrote:
> >  int xen_irq_from_pirq(unsigned pirq)
> >  {
> > -   return pirq_to_irq[pirq];
> > +   int irq;
> > +
> > +   struct irq_info *info;
> > +
> > +   spin_lock(&irq_mapping_update_lock);
> > +
> > +   list_for_each_entry(info, &xen_irq_list_head, list) {
> > +           if (info == NULL || info->type != IRQT_PIRQ)
> > +                   continue;
> > +           irq = info->irq;
> > +           if (info->u.pirq.pirq == pirq)
> > +                   goto out;
> > +   }
> > +   irq = -1;
> > +out:
> > +   spin_lock(&irq_mapping_update_lock);
> > +
> > +   return -1;
> 
> Shouldn't this be:
> 
>   return irq

Yes. The impact of not doing so is that xen_hvm_setup_msi_irqs would
allocate a fresh PIRQ each time an MSI was reused, instead of resuing
the old one -- i.e. it's a leak. I retested PVHVM PCI hotplug with the
following patch.

> How come you are using the spin_lock here, but not
> in other places when iterating over the xen_irq_list_head?

Those other places already hold the lock in their caller (or are known
to be single threaded -- e.g. resume). Callers of xen_irq_from_pirq do
not hold the lock.

Ian.

8<------------------------

>From 9b1686b874c4893a3b014e400185940dcba43676 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 10 Mar 2011 08:54:06 +0000
Subject: [PATCH] xen: events: fix return value from xen_irq_from_pirq

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 drivers/xen/events.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 77c2b43..dc5b575 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -765,7 +765,7 @@ int xen_irq_from_pirq(unsigned pirq)
 out:
        spin_lock(&irq_mapping_update_lock);
 
-       return -1;
+       return irq;
 }
 
 
-- 
1.5.6.5




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>