ia64/xen-unstable

changeset 18804:ae891977a4d3

x86, hvm: Implement interrupt routing to least priority processor.

Instead of round robin the vcpu with the lowest processor
priority is selected for the interrupt. If multiple vcpus
share the same low priority then interrupts are distributed between
those round robin.

Signed-off-by: Juergen Gross <juergen.gross@fujitsu-siemens.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Nov 18 11:16:36 2008 +0000 (2008-11-18)
parents 2604400f75e3
children 85fda344dba7
files xen/arch/x86/hvm/vioapic.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmsi.c xen/include/asm-x86/hvm/vlapic.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vioapic.c	Tue Nov 18 10:52:42 2008 +0000
     1.2 +++ b/xen/arch/x86/hvm/vioapic.c	Tue Nov 18 11:16:36 2008 +0000
     1.3 @@ -344,8 +344,8 @@ static void vioapic_deliver(struct hvm_h
     1.4          }
     1.5          else
     1.6  #endif
     1.7 -            target = apic_round_robin(vioapic_domain(vioapic),
     1.8 -                                      vector, deliver_bitmask);
     1.9 +            target = apic_lowest_prio(vioapic_domain(vioapic),
    1.10 +                                      deliver_bitmask);
    1.11          if ( target != NULL )
    1.12          {
    1.13              ioapic_inj_irq(vioapic, target, vector, trig_mode, delivery_mode);
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Nov 18 10:52:42 2008 +0000
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Nov 18 11:16:36 2008 +0000
     2.3 @@ -377,26 +377,30 @@ static int vlapic_accept_irq(struct vcpu
     2.4  }
     2.5  
     2.6  /* This function is used by both ioapic and lapic.The bitmap is for vcpu_id. */
     2.7 -struct vlapic *apic_round_robin(
     2.8 -    struct domain *d, uint8_t vector, uint32_t bitmap)
     2.9 +struct vlapic *apic_lowest_prio(struct domain *d, uint32_t bitmap)
    2.10  {
    2.11 -    int next, old;
    2.12 -    struct vlapic *target = NULL;
    2.13 +    int old = d->arch.hvm_domain.irq.round_robin_prev_vcpu;
    2.14 +    uint32_t ppr, target_ppr = UINT_MAX;
    2.15 +    struct vlapic *vlapic, *target = NULL;
    2.16 +    struct vcpu *v;
    2.17  
    2.18 -    old = next = d->arch.hvm_domain.irq.round_robin_prev_vcpu;
    2.19 +    if ( unlikely((v = d->vcpu[old]) == NULL) )
    2.20 +        return NULL;
    2.21  
    2.22      do {
    2.23 -        if ( ++next == MAX_VIRT_CPUS ) 
    2.24 -            next = 0;
    2.25 -        if ( (d->vcpu[next] == NULL) || !test_bit(next, &bitmap) )
    2.26 -            continue;
    2.27 -        target = vcpu_vlapic(d->vcpu[next]);
    2.28 -        if ( vlapic_enabled(target) )
    2.29 -            break;
    2.30 -        target = NULL;
    2.31 -    } while ( next != old );
    2.32 +        v = v->next_in_list ? : d->vcpu[0];
    2.33 +        vlapic = vcpu_vlapic(v);
    2.34 +        if ( test_bit(v->vcpu_id, &bitmap) && vlapic_enabled(vlapic) &&
    2.35 +             ((ppr = vlapic_get_ppr(vlapic)) < target_ppr) )
    2.36 +        {
    2.37 +            target = vlapic;
    2.38 +            target_ppr = ppr;
    2.39 +        }
    2.40 +    } while ( v->vcpu_id != old );
    2.41  
    2.42 -    d->arch.hvm_domain.irq.round_robin_prev_vcpu = next;
    2.43 +    if ( target != NULL )
    2.44 +        d->arch.hvm_domain.irq.round_robin_prev_vcpu =
    2.45 +            vlapic_vcpu(target)->vcpu_id;
    2.46  
    2.47      return target;
    2.48  }
    2.49 @@ -456,7 +460,7 @@ int vlapic_ipi(
    2.50  
    2.51      if ( delivery_mode == APIC_DM_LOWEST )
    2.52      {
    2.53 -        target = apic_round_robin(vlapic_domain(v), vector, lpr_map);
    2.54 +        target = apic_lowest_prio(vlapic_domain(v), lpr_map);
    2.55          if ( target != NULL )
    2.56              rc = vlapic_accept_irq(vlapic_vcpu(target), delivery_mode,
    2.57                                     vector, level, trig_mode);
     3.1 --- a/xen/arch/x86/hvm/vmsi.c	Tue Nov 18 10:52:42 2008 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmsi.c	Tue Nov 18 11:16:36 2008 +0000
     3.3 @@ -152,7 +152,7 @@ int vmsi_deliver(struct domain *d, int p
     3.4      {
     3.5      case dest_LowestPrio:
     3.6      {
     3.7 -        target = apic_round_robin(d, vector, deliver_bitmask);
     3.8 +        target = apic_lowest_prio(d, deliver_bitmask);
     3.9          if ( target != NULL )
    3.10              vmsi_inj_irq(d, target, vector, trig_mode, delivery_mode);
    3.11          else
     4.1 --- a/xen/include/asm-x86/hvm/vlapic.h	Tue Nov 18 10:52:42 2008 +0000
     4.2 +++ b/xen/include/asm-x86/hvm/vlapic.h	Tue Nov 18 11:16:36 2008 +0000
     4.3 @@ -93,8 +93,7 @@ void vlapic_msr_set(struct vlapic *vlapi
     4.4  
     4.5  int vlapic_accept_pic_intr(struct vcpu *v);
     4.6  
     4.7 -struct vlapic *apic_round_robin(
     4.8 -    struct domain *d, uint8_t vector, uint32_t bitmap);
     4.9 +struct vlapic *apic_lowest_prio(struct domain *d, uint32_t bitmap);
    4.10  
    4.11  int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda);
    4.12