All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: julien.grall@citrix.com, jtd@galois.com,
	xen-devel@lists.xensource.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH v4 10/10] xen/arm: gic_events_need_delivery and irq priorities
Date: Mon, 24 Mar 2014 13:06:47 +0000	[thread overview]
Message-ID: <alpine.DEB.2.02.1403241255130.8273@kaball.uk.xensource.com> (raw)
In-Reply-To: <1395662736.6294.8.camel@kazak.uk.xensource.com>

On Mon, 24 Mar 2014, Ian Campbell wrote:
> On Mon, 2014-03-24 at 12:00 +0000, Stefano Stabellini wrote:
> > On Fri, 21 Mar 2014, Ian Campbell wrote:
> > > On Wed, 2014-03-19 at 12:32 +0000, Stefano Stabellini wrote:
> > > > gic_events_need_delivery should only return positive if an outstanding
> > > > pending irq has an higher priority than the currently active irq and the
> > > > priority mask.
> > > > Rewrite the function by going through the priority ordered inflight and
> > > > lr_queue lists.
> > > > 
> > > > In gic_restore_pending_irqs replace lower priority pending (and not
> > > > active) irqs in GICH_LRs with higher priority irqs if no more GICH_LRs
> > > > are available.
> > > > 
> > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > > > 
> > > > ---
> > > > Changes in v4:
> > > > - in gic_events_need_delivery go through inflight_irqs and only consider
> > > > enabled irqs.
> > > > ---
> > > >  xen/arch/arm/gic.c           |   71 +++++++++++++++++++++++++++++++++++++-----
> > > >  xen/include/asm-arm/domain.h |    5 +--
> > > >  xen/include/asm-arm/gic.h    |    3 ++
> > > >  3 files changed, 70 insertions(+), 9 deletions(-)
> > > > 
> > > > diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> > > > index bc9d66d..533964e 100644
> > > > --- a/xen/arch/arm/gic.c
> > > > +++ b/xen/arch/arm/gic.c
> > > > @@ -709,6 +709,7 @@ static void _gic_clear_lr(struct vcpu *v, int i)
> > > >      p = irq_to_pending(v, irq);
> > > >      if ( lr & GICH_LR_ACTIVE )
> > > >      {
> > > > +        set_bit(GIC_IRQ_GUEST_ACTIVE, &p->status);
> > > >          /* HW interrupts cannot be ACTIVE and PENDING */
> > > >          if ( p->desc == NULL &&
> > > >               test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) &&
> > > > @@ -723,6 +724,7 @@ static void _gic_clear_lr(struct vcpu *v, int i)
> > > >          if ( p->desc != NULL )
> > > >              p->desc->status &= ~IRQ_INPROGRESS;
> > > >          clear_bit(GIC_IRQ_GUEST_VISIBLE, &p->status);
> > > > +        clear_bit(GIC_IRQ_GUEST_ACTIVE, &p->status);
> > > >          p->lr = nr_lrs;
> > > >          if ( test_bit(GIC_IRQ_GUEST_PENDING, &p->status) &&
> > > >                  test_bit(GIC_IRQ_GUEST_ENABLED, &p->status))
> > > > @@ -750,22 +752,47 @@ void gic_clear_lrs(struct vcpu *v)
> > > >  
> > > >  static void gic_restore_pending_irqs(struct vcpu *v)
> > > >  {
> > > > -    int i;
> > > > -    struct pending_irq *p, *t;
> > > > +    int i = 0, lrs = nr_lrs;
> > > > +    struct pending_irq *p, *t, *p_r;
> > > >      unsigned long flags;
> > > >  
> > > > +    if ( list_empty(&v->arch.vgic.lr_pending) )
> > > > +        return;
> > > > +
> > > > +    spin_lock_irqsave(&v->arch.vgic.lock, flags);
> > > > +
> > > > +    p_r = list_entry(v->arch.vgic.inflight_irqs.prev,
> > > > +                         typeof(*p_r), inflight);
> > > 
> > > Is this getting the tail of the list or something else?
> > > 
> > > >      list_for_each_entry_safe ( p, t, &v->arch.vgic.lr_pending, lr_queue )
> > > >      {
> > > >          i = find_first_zero_bit(&this_cpu(lr_mask), nr_lrs);
> > > > -        if ( i >= nr_lrs ) return;
> > > > +        if ( i >= nr_lrs )
> > > > +        {
> > > > +            while ( !test_bit(GIC_IRQ_GUEST_VISIBLE, &p_r->status) ||
> > > > +                    test_bit(GIC_IRQ_GUEST_ACTIVE, &p_r->status) )
> > > > +            {
> > > > +                p_r = list_entry(p_r->inflight.prev, typeof(*p_r), inflight);
> > > 
> > > Oh, maybe this (and the thing above) is an open coded list_for_each_prev
> > > or one of its variants? e.g. list_for_each_entry_reverse?
> > 
> > Yes, it is a list_for_each_entry_reverse that starts from the current
> > p_r and stops when it finds the first entry that is
> > GIC_IRQ_GUEST_VISIBLE and GIC_IRQ_GUEST_ACTIVE.
> 
> I think this can/should be recast in terms of the regular macro then.

OK.
We'll need to introduce list_for_each_entry_continue_reverse.

> > It can also stop if the next entry that would be found going through
> > inflight in reverse is the same that we are evaluating going through
> > lr_pending in regular order.
> 
> I think it should also be possible to incorporate this behaviour.
> 
> But is it worth going backwards? I'd have though that for a long list of
> inflight interrupts the normal case would be a smallish number of
> VISIBLE+ACTIVE interrupts at the head and a potentially larger tail up
> to nr_lrs. So you would be better off searching in normal order.

I think it is worth going backward to get the lowest priority interrupt
currently being injected. Inflight is also ordered by priority.

  reply	other threads:[~2014-03-24 13:06 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 12:31 [PATCH v4 0/10] remove maintenance interrupts Stefano Stabellini
2014-03-19 12:31 ` [PATCH v4 01/10] xen/arm: no need to set HCR_VI when using the vgic to inject irqs Stefano Stabellini
2014-03-19 13:33   ` Julien Grall
2014-03-21 14:06   ` Ian Campbell
2014-03-19 12:31 ` [PATCH v4 02/10] xen/arm: remove unused virtual parameter from vgic_vcpu_inject_irq Stefano Stabellini
2014-03-19 12:31 ` [PATCH v4 03/10] xen/arm: support HW interrupts, do not request maintenance_interrupts Stefano Stabellini
2014-03-19 13:42   ` Julien Grall
2014-03-19 14:43     ` Stefano Stabellini
2014-03-19 15:11       ` Julien Grall
2014-03-19 15:53         ` Stefano Stabellini
2014-03-19 16:10           ` Julien Grall
2014-03-21 13:04   ` Ian Campbell
2014-03-21 15:55     ` Stefano Stabellini
2014-03-21 16:16       ` Ian Campbell
2014-03-24 12:11         ` Stefano Stabellini
2014-03-24 12:15           ` Ian Campbell
2014-03-19 12:31 ` [PATCH v4 04/10] xen/arm: set GICH_HCR_UIE if all the LRs are in use Stefano Stabellini
2014-03-19 13:49   ` Julien Grall
2014-03-21 13:06   ` Ian Campbell
2014-03-21 16:03     ` Stefano Stabellini
2014-03-21 13:07   ` Ian Campbell
2014-03-21 16:05     ` Stefano Stabellini
2014-03-19 12:32 ` [PATCH v4 05/10] xen/arm: keep track of the GICH_LR used for the irq in struct pending_irq Stefano Stabellini
2014-03-19 13:52   ` Julien Grall
2014-03-19 14:45     ` Stefano Stabellini
2014-03-21 13:11   ` Ian Campbell
2014-03-21 16:19     ` Stefano Stabellini
2014-03-21 16:25       ` Ian Campbell
2014-03-24 12:12         ` Stefano Stabellini
2014-03-19 12:32 ` [PATCH v4 06/10] xen/arm: s/gic_set_guest_irq/gic_raise_guest_irq Stefano Stabellini
2014-03-19 13:53   ` Julien Grall
2014-03-21 13:12   ` Ian Campbell
2014-03-21 16:20     ` Stefano Stabellini
2014-03-21 16:26       ` Ian Campbell
2014-03-19 12:32 ` [PATCH v4 07/10] xen/arm: call gic_clear_lrs on entry to the hypervisor Stefano Stabellini
2014-03-19 13:56   ` Julien Grall
2014-03-21 13:14   ` Ian Campbell
2014-03-21 16:34     ` Stefano Stabellini
2014-03-21 16:39       ` Ian Campbell
2014-03-24 12:24         ` Stefano Stabellini
2014-03-19 12:32 ` [PATCH v4 08/10] xen/arm: second irq injection while the first irq is still inflight Stefano Stabellini
2014-03-21 13:22   ` Ian Campbell
2014-03-21 16:46     ` Stefano Stabellini
2014-03-21 17:04       ` Ian Campbell
2014-03-24 12:54         ` Stefano Stabellini
2014-03-24 12:57           ` Ian Campbell
2014-03-24 16:41             ` Stefano Stabellini
2014-03-25 10:09               ` Ian Campbell
2014-03-19 12:32 ` [PATCH v4 09/10] xen/arm: don't protect GICH and lr_queue accesses with gic.lock Stefano Stabellini
2014-03-21 13:31   ` Ian Campbell
2014-03-21 17:07     ` Stefano Stabellini
2014-03-19 12:32 ` [PATCH v4 10/10] xen/arm: gic_events_need_delivery and irq priorities Stefano Stabellini
2014-03-19 14:00   ` Julien Grall
2014-03-20 11:03     ` Ian Campbell
2014-03-20 15:10       ` Julien Grall
2014-03-20 15:14         ` Ian Campbell
2014-03-21 13:42   ` Ian Campbell
2014-03-24 12:00     ` Stefano Stabellini
2014-03-24 12:05       ` Ian Campbell
2014-03-24 13:06         ` Stefano Stabellini [this message]
2014-03-24 16:06           ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1403241255130.8273@kaball.uk.xensource.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=jtd@galois.com \
    --cc=julien.grall@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.