All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: "Wu, Feng" <feng.wu@intel.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: "Zhang, Yang Z" <yang.z.zhang@intel.com>,
	"keir@xen.org" <keir@xen.org>,
	"JBeulich@suse.com" <JBeulich@suse.com>
Subject: Re: [RFC v1 11/15] vmx: Add a global wake-up vector for VT-d Posted-Interrupts
Date: Thu, 2 Apr 2015 06:00:32 +0000	[thread overview]
Message-ID: <AADFC41AFE54684AB9EE6CBC0274A5D1261FB700@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1427286717-4093-12-git-send-email-feng.wu@intel.com>

> From: Wu, Feng
> Sent: Wednesday, March 25, 2015 8:32 PM
> 
> This patch adds a global vector which is used to wake up
> the blocked vCPU when an interrupt is being posted to it.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> Suggested-by: Yang Zhang <yang.z.zhang@intel.com>
> ---
>  xen/arch/x86/hvm/vmx/vmx.c        | 33
> +++++++++++++++++++++++++++++++++
>  xen/include/asm-x86/hvm/hvm.h     |  1 +
>  xen/include/asm-x86/hvm/vmx/vmx.h |  3 +++
>  xen/include/xen/sched.h           |  2 ++
>  4 files changed, 39 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index ff5544d..b2b4c26 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -89,6 +89,7 @@ DEFINE_PER_CPU(struct list_head,
> blocked_vcpu_on_cpu);
>  DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock);
> 
>  uint8_t __read_mostly posted_intr_vector;
> +uint8_t __read_mostly pi_wakeup_vector;
> 
>  static int vmx_domain_initialise(struct domain *d)
>  {
> @@ -131,6 +132,8 @@ static int vmx_vcpu_initialise(struct vcpu *v)
>      if ( v->vcpu_id == 0 )
>          v->arch.user_regs.eax = 1;
> 
> +    INIT_LIST_HEAD(&v->blocked_vcpu_list);
> +
>      return 0;
>  }
> 
> @@ -1834,11 +1837,19 @@ const struct hvm_function_table * __init
> start_vmx(void)
>      }
> 
>      if ( cpu_has_vmx_posted_intr_processing )
> +    {
>          alloc_direct_apic_vector(&posted_intr_vector,
> event_check_interrupt);
> +
> +        if ( iommu_intpost )
> +            alloc_direct_apic_vector(&pi_wakeup_vector,
> pi_wakeup_interrupt);
> +        else
> +            vmx_function_table.pi_desc_update = NULL;
> +    }

just style issue. Above conditional logic looks not intuitive to me.
usually we have:
	if ( iommu_intpost )
		vmx_function_table.pi_desc_update = func;
	else
		vmx_function_table.pi_desc_update = NULL;

suppose you will register callback in later patch. then better to
move the NULL one there too. Putting it here doesn't meet the
normal if...else implications. :-)

>      else
>      {
>          vmx_function_table.deliver_posted_intr = NULL;
>          vmx_function_table.sync_pir_to_irr = NULL;
> +        vmx_function_table.pi_desc_update = NULL;
>      }
> 
>      if ( cpu_has_vmx_ept
> @@ -3255,6 +3266,28 @@ void vmx_vmenter_helper(const struct
> cpu_user_regs *regs)
>  }
> 
>  /*
> + * Handle VT-d posted-interrupt when VCPU is blocked.
> + */
> +void pi_wakeup_interrupt(struct cpu_user_regs *regs)
> +{
> +    struct vcpu *v;
> +    int cpu = smp_processor_id();
> +
> +    spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
> +    list_for_each_entry(v, &per_cpu(blocked_vcpu_on_cpu, cpu),
> +                    blocked_vcpu_list) {
> +        struct pi_desc *pi_desc = &v->arch.hvm_vmx.pi_desc;
> +
> +        if ( pi_test_on(pi_desc) == 1 )
> +            tasklet_schedule(&v->vcpu_wakeup_tasklet);

why can't we directly call vcpu_unblock here?

> +    }
> +    spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
> +
> +    ack_APIC_irq();
> +    this_cpu(irq_count)++;
> +}
> +
> +/*
>   * Local variables:
>   * mode: C
>   * c-file-style: "BSD"
> diff --git a/xen/include/asm-x86/hvm/hvm.h
> b/xen/include/asm-x86/hvm/hvm.h
> index 0dc909b..a11a256 100644
> --- a/xen/include/asm-x86/hvm/hvm.h
> +++ b/xen/include/asm-x86/hvm/hvm.h
> @@ -195,6 +195,7 @@ struct hvm_function_table {
>      void (*deliver_posted_intr)(struct vcpu *v, u8 vector);
>      void (*sync_pir_to_irr)(struct vcpu *v);
>      void (*handle_eoi)(u8 vector);
> +    void (*pi_desc_update)(struct vcpu *v, int new_state);
> 
>      /*Walk nested p2m  */
>      int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa,
> diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h
> b/xen/include/asm-x86/hvm/vmx/vmx.h
> index e643c3c..f4296ab 100644
> --- a/xen/include/asm-x86/hvm/vmx/vmx.h
> +++ b/xen/include/asm-x86/hvm/vmx/vmx.h
> @@ -34,6 +34,7 @@ DECLARE_PER_CPU(struct list_head,
> blocked_vcpu_on_cpu);
>  DECLARE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock);
> 
>  extern uint8_t posted_intr_vector;
> +extern uint8_t pi_wakeup_vector;
> 
>  typedef union {
>      struct {
> @@ -574,6 +575,8 @@ int alloc_p2m_hap_data(struct p2m_domain *p2m);
>  void free_p2m_hap_data(struct p2m_domain *p2m);
>  void p2m_init_hap_data(struct p2m_domain *p2m);
> 
> +void pi_wakeup_interrupt(struct cpu_user_regs *regs);
> +
>  /* EPT violation qualifications definitions */
>  #define _EPT_READ_VIOLATION         0
>  #define EPT_READ_VIOLATION          (1UL<<_EPT_READ_VIOLATION)
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index c874dd4..91f0912 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -148,6 +148,8 @@ struct vcpu
> 
>      struct vcpu     *next_in_list;
> 
> +    struct list_head blocked_vcpu_list;
> +
>      s_time_t         periodic_period;
>      s_time_t         periodic_last_event;
>      struct timer     periodic_timer;
> --
> 2.1.0

  parent reply	other threads:[~2015-04-02  6:00 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 12:31 [RFC v1 00/15] Add VT-d Posted-Interrupts support Feng Wu
2015-03-25 12:31 ` [RFC v1 01/15] iommu: Add iommu_intpost to control VT-d Posted-Interrupts feature Feng Wu
2015-03-26 17:39   ` Andrew Cooper
2015-03-27  4:46     ` Wu, Feng
2015-03-27  9:55       ` Andrew Cooper
2015-03-27  9:52     ` Jan Beulich
2015-03-25 12:31 ` [RFC v1 02/15] vt-d: VT-d Posted-Interrupts feature detection Feng Wu
2015-03-26 18:12   ` Andrew Cooper
2015-03-27  1:21     ` Wu, Feng
2015-03-27 10:06       ` Andrew Cooper
2015-03-27 13:41         ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 03/15] vmx: Extend struct pi_desc to support VT-d Posted-Interrupts Feng Wu
2015-03-26 18:37   ` Andrew Cooper
2015-03-27  1:32     ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 04/15] vmx: Add some helper functions for Posted-Interrupts Feng Wu
2015-03-26 18:44   ` Andrew Cooper
2015-03-25 12:31 ` [RFC v1 05/15] vmx: Initialize VT-d Posted-Interrupts Descriptor Feng Wu
2015-03-26 18:53   ` Andrew Cooper
2015-03-27  1:45     ` Wu, Feng
2015-03-26 19:29   ` Konrad Rzeszutek Wilk
2015-03-27  1:45     ` Wu, Feng
2015-05-04  5:32     ` Wu, Feng
2015-05-04  8:10       ` Jan Beulich
2015-05-04  8:36       ` Andrew Cooper
2015-05-04  9:07         ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 06/15] vt-d: Extend struct iremap_entry to support VT-d Posted-Interrupts Feng Wu
2015-03-26 19:00   ` Andrew Cooper
2015-03-27  1:53     ` Wu, Feng
2015-03-27  9:58       ` Jan Beulich
2015-04-02  6:32         ` Tian, Kevin
2015-03-25 12:31 ` [RFC v1 07/15] vt-d: Add API to update IRTE when VT-d PI is used Feng Wu
2015-03-26 19:17   ` Andrew Cooper
2015-03-27  2:13     ` Wu, Feng
2015-03-27 10:02       ` Jan Beulich
2015-03-27  4:52     ` Wu, Feng
2015-03-26 19:36   ` Konrad Rzeszutek Wilk
2015-03-27  1:59     ` Wu, Feng
2015-04-02  5:34   ` Tian, Kevin
2015-04-02  6:02     ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 08/15] Update IRTE according to guest interrupt config changes Feng Wu
2015-03-26 19:46   ` Konrad Rzeszutek Wilk
2015-03-27  5:45     ` Wu, Feng
2015-03-26 19:59   ` Andrew Cooper
2015-03-27  5:49     ` Wu, Feng
2015-03-27 11:31       ` Andrew Cooper
2015-04-02  5:52   ` Tian, Kevin
2015-04-02  6:20     ` Wu, Feng
2015-04-02  6:49       ` Tian, Kevin
2015-04-02  8:02         ` Wu, Feng
2015-04-03  8:29           ` Tian, Kevin
2015-03-25 12:31 ` [RFC v1 09/15] Add a new per-vCPU tasklet to wakeup the blocked vCPU Feng Wu
2015-04-02  5:53   ` Tian, Kevin
2015-04-02  7:20     ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 10/15] vmx: Define two per-cpu variants Feng Wu
2015-03-26 19:59   ` Andrew Cooper
2015-04-02  5:54   ` Tian, Kevin
2015-04-02  6:24     ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 11/15] vmx: Add a global wake-up vector for VT-d Posted-Interrupts Feng Wu
2015-03-26 20:07   ` Andrew Cooper
2015-04-02  6:00   ` Tian, Kevin [this message]
2015-04-02  7:18     ` Wu, Feng
2015-04-08  9:02       ` Tian, Kevin
2015-04-08 11:14         ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 12/15] vmx: Properly handle notification event when vCPU is running Feng Wu
2015-03-25 14:14   ` Zhang, Yang Z
2015-03-27  4:40     ` Wu, Feng
2015-03-27  4:44       ` Zhang, Yang Z
2015-03-27  4:57         ` Wu, Feng
2015-04-02  6:08           ` Tian, Kevin
2015-04-02  7:21             ` Wu, Feng
2015-04-02 19:15             ` Konrad Rzeszutek Wilk
2015-04-03  2:00               ` Wu, Feng
2015-04-03 13:36                 ` Konrad Rzeszutek Wilk
2015-04-07  0:35                   ` Wu, Feng
2015-03-26 19:57   ` Konrad Rzeszutek Wilk
2015-03-27  3:06     ` Wu, Feng
2015-03-25 12:31 ` [RFC v1 13/15] Update Posted-Interrupts Descriptor during vCPU scheduling Feng Wu
2015-03-26 20:16   ` Andrew Cooper
2015-03-27  2:59     ` Wu, Feng
2015-04-02  6:24   ` Tian, Kevin
2015-04-02  8:39     ` Wu, Feng
2015-04-08  8:53       ` Tian, Kevin
2015-04-08 11:01         ` Wu, Feng
2015-04-09  2:37           ` Tian, Kevin
2015-03-25 12:31 ` [RFC v1 14/15] Suppress posting interrupts when 'SN' is set Feng Wu
2015-03-26 20:34   ` Andrew Cooper
2015-03-27  3:00     ` Wu, Feng
2015-03-27 12:06       ` Andrew Cooper
2015-03-27 13:45         ` Wu, Feng
2015-03-27 13:49           ` Andrew Cooper
2015-03-30  2:11             ` Wu, Feng
2015-03-30 10:11               ` Andrew Cooper
2015-03-25 12:31 ` [RFC v1 15/15] Add a command line parameter for VT-d posted-interrupts Feng Wu
2015-03-26 18:50 ` [RFC v1 00/15] Add VT-d Posted-Interrupts support Konrad Rzeszutek Wilk
2015-03-27  1:06   ` Wu, Feng
2015-03-27 14:44     ` Konrad Rzeszutek Wilk
2015-04-01 13:21 ` Wu, Feng
2015-04-13 12:12   ` Jan Beulich
2015-04-13 23:38     ` Wu, Feng
2015-04-24 17:50     ` Wu, Feng
2015-04-27 23:40       ` Jan Beulich

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=AADFC41AFE54684AB9EE6CBC0274A5D1261FB700@SHSMSX101.ccr.corp.intel.com \
    --to=kevin.tian@intel.com \
    --cc=JBeulich@suse.com \
    --cc=feng.wu@intel.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xen.org \
    --cc=yang.z.zhang@intel.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.