All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: julien.grall@citrix.com, xen-devel@lists.xensource.com
Subject: Re: [PATCH v8 03/10] xen/arm: inflight irqs during migration
Date: Thu, 17 Jul 2014 13:44:11 +0100	[thread overview]
Message-ID: <1405601051.31127.9.camel@kazak.uk.xensource.com> (raw)
In-Reply-To: <1405016003-19131-3-git-send-email-stefano.stabellini@eu.citrix.com>

On Thu, 2014-07-10 at 19:13 +0100, Stefano Stabellini wrote:
> We need to take special care when migrating irqs that are already
> inflight from one vcpu to another. See "The effect of changes to an
> GICD_ITARGETSR", part of chapter 4.3.12 of the ARM Generic Interrupt
> Controller Architecture Specification.
> 
> The main issue from the Xen point of view is that the lr_pending and
> inflight lists are per-vcpu. The lock we take to protect them is also
> per-vcpu.
> 
> In order to avoid issues, if the irq is still lr_pending, we can
> immediately move it to the new vcpu for injection.
> 
> Otherwise if it is in a GICH_LR register, set a new flag
> GIC_IRQ_GUEST_MIGRATING, so that we can recognize when we receive an irq
> while the previous one is still inflight (given that we are only dealing
> with hardware interrupts here, it just means that its LR hasn't been
> cleared yet on the old vcpu).  If GIC_IRQ_GUEST_MIGRATING is set, we
> only set GIC_IRQ_GUEST_QUEUED and interrupt the old vcpu. To know which
> one is the old vcpu, we introduce a new field to pending_irq, called
> vcpu_migrate_from.
> When clearing the LR on the old vcpu, we take special care of injecting
> the interrupt into the new vcpu. To do that we need to release the old
> vcpu lock before taking the new vcpu lock.

I still think this is an awful lot of complexity and scaffolding for
something which is rare on the scale of things and which could be almost
trivially handled by requesting a maintenance interrupt for one EOI and
completing the move at that point.

In order to avoid a simple maint interrupt you are adding code to the
normal interrupt path and a potential SGI back to another processor (and
I hope I'm misreading this but it looks like an SGI back again to finish
off?). That's got to be way more costly to the first interrupt on the
new VCPU than the cost of a maintenance IRQ on the old one.

I think avoiding maintenance interrupts in general is a worthy goal, but
there are times when they are the most appropriate mechanism.

> @@ -344,6 +385,21 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)
>      }
>  
>      set_bit(GIC_IRQ_GUEST_QUEUED, &n->status);
> +    vcpu_migrate_from = n->vcpu_migrate_from;
> +    /* update QUEUED before MIGRATING */
> +    smp_wmb();
> +    if ( test_bit(GIC_IRQ_GUEST_MIGRATING, &n->status) )
> +    {
> +        spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
> +
> +        /* The old vcpu must have EOIed the SGI but not cleared the LR.
> +         * Give it a kick. */

You mean SPI I think.

Ian.

  reply	other threads:[~2014-07-17 12:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10 18:12 [PATCH v8 00/10] gic and vgic fixes and improvements Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 01/10] xen/arm: observe itargets setting in vgic_enable_irqs and vgic_disable_irqs Stefano Stabellini
2014-07-11 13:01   ` Julien Grall
2014-07-23 15:31     ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 02/10] xen/arm: move setting GIC_IRQ_GUEST_QUEUED earlier Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 03/10] xen/arm: inflight irqs during migration Stefano Stabellini
2014-07-17 12:44   ` Ian Campbell [this message]
2014-07-23 14:45     ` Stefano Stabellini
2014-07-23 15:38       ` Ian Campbell
2014-07-24 14:48         ` Stefano Stabellini
2014-07-24 16:41           ` Ian Campbell
2014-07-24 16:45             ` Stefano Stabellini
2014-07-24 16:48               ` Ian Campbell
2014-07-24 16:49                 ` Stefano Stabellini
2014-07-25  9:08                   ` Ian Campbell
2014-07-10 18:13 ` [PATCH v8 04/10] xen/arm: support irq delivery to vcpu > 0 Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 05/10] xen/arm: physical irq follow virtual irq Stefano Stabellini
2014-07-11 13:07   ` Julien Grall
2014-07-23 15:00     ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 06/10] xen: introduce sched_move_irqs Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 07/10] xen/arm: remove workaround to inject evtchn_irq on irq enable Stefano Stabellini
2014-07-11 13:10   ` Julien Grall
2014-07-17 12:50   ` Ian Campbell
2014-07-23 15:04     ` Stefano Stabellini
2014-07-23 16:09       ` Stefano Stabellini
2014-07-23 16:11         ` Ian Campbell
2014-07-23 16:12           ` Stefano Stabellini
2014-07-23 16:16             ` Ian Campbell
2014-07-24 14:37               ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 08/10] xen/arm: take the rank lock before accessing ipriority Stefano Stabellini
2014-07-17 12:51   ` Ian Campbell
2014-07-23 14:57     ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 09/10] xen: introduce bit access macros for the IRQ line status flags Stefano Stabellini
2014-07-11 13:15   ` Julien Grall
2014-07-23 14:52     ` Stefano Stabellini
2014-07-10 18:13 ` [PATCH v8 10/10] xen/arm: make accesses to desc->status flags atomic Stefano Stabellini
2014-07-17 12:52   ` Ian Campbell

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=1405601051.31127.9.camel@kazak.uk.xensource.com \
    --to=ian.campbell@citrix.com \
    --cc=julien.grall@citrix.com \
    --cc=stefano.stabellini@eu.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.