All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Feng Wu <feng.wu@intel.com>, xen-devel@lists.xen.org
Cc: george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	kevin.tian@intel.com, jbeulich@suse.com
Subject: Re: [PATCH v3 3/6] VMX: Cleanup PI per-cpu blocking list when vcpu is destroyed
Date: Tue, 6 Sep 2016 11:21:33 +0200	[thread overview]
Message-ID: <1473153693.19612.103.camel@citrix.com> (raw)
In-Reply-To: <1472615791-8664-4-git-send-email-feng.wu@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 3455 bytes --]

On Wed, 2016-08-31 at 11:56 +0800, Feng Wu wrote:
> We should remove the vCPU from the per-cpu blocking list
> if it is going to be destroyed.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index b869728..37fa2f1 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -346,6 +346,7 @@ static void vmx_vcpu_destroy(struct vcpu *v)
>      vmx_destroy_vmcs(v);
>      vpmu_destroy(v);
>      passive_domain_destroy(v);
> +    vmx_pi_blocking_cleanup(v);
>
I'm not too much into VMX, so I may be wrong (in which case, sorry),
but is it safe to call this after vmx_destroy_vmcs() ?

Also (even if it is), we're basically calling and executing the
following (called by vmx_pi_blocking_clanup()):

static void vmx_pi_remove_vcpu_from_blocking_list(struct vcpu *v)
{
    unsigned long flags;
    spinlock_t *pi_blocking_list_lock;
    struct pi_desc *pi_desc = &v->arch.hvm_vmx.pi_desc;

    /*
     * Set 'NV' field back to posted_intr_vector, so the
     * Posted-Interrupts can be delivered to the vCPU when
     * it is running in non-root mode.
     */
    write_atomic(&pi_desc->nv, posted_intr_vector);

    /* The vCPU is not on any blocking list. */
    pi_blocking_list_lock = v->arch.hvm_vmx.pi_blocking.lock;

    /* Prevent the compiler from eliminating the local variable.*/
    smp_rmb();

    if ( pi_blocking_list_lock == NULL )
        return;

    spin_lock_irqsave(pi_blocking_list_lock, flags);

    /*
     * v->arch.hvm_vmx.pi_blocking.lock == NULL here means the vCPU
     * was removed from the blocking list while we are acquiring the lock.
     */
    if ( v->arch.hvm_vmx.pi_blocking.lock != NULL )
    {
        ASSERT(v->arch.hvm_vmx.pi_blocking.lock == pi_blocking_list_lock);
        list_del(&v->arch.hvm_vmx.pi_blocking.list);
        v->arch.hvm_vmx.pi_blocking.lock = NULL;
    }

    spin_unlock_irqrestore(pi_blocking_list_lock, flags);
}

Considering that we're destroying, isn't this too much? Maybe it's not
a big deal, but I'd have expected that all is needed here is something
like:

 if ( v->arch.hvm_vmx.pi_blocking.lock )
 {
     spin_lock_irqsave(..);
     list_del(..);
     spin_unlock_irqrestore(..);
 }

Maybe the resume, list_remove, and cleanup functions need to be broken
up a bit more/better?

Also, as a side note (which I think would be more appropriate as a
comment to patch 1, but bear with me, I'm just back from vacations, I
have a lot of catch up to do, and I'm in hurry! :-P), now that the
function is called vmx_pi_remove_vcpu_from_blocking_list(), this
comment being part of its body sounds a bit weird:

    ...
    /* The vCPU is not on any blocking list. */
    pi_blocking_list_loc
k = v->arch.hvm_vmx.pi_blocking.lock;
    ...

I'd take the chance for rephrasing it.

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-09-06  9:21 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31  3:56 [PATCH v3 0/6] VMX: Properly handle pi descriptor and per-cpu blocking list Feng Wu
2016-08-31  3:56 ` [PATCH v3 1/6] VMX: Statically assign two PI hooks Feng Wu
2016-09-01  8:16   ` Jan Beulich
2016-09-01  9:13     ` Wu, Feng
2016-09-01  9:23       ` Jan Beulich
2016-09-01  9:38         ` Wu, Feng
2016-09-06  8:42   ` Dario Faggioli
2016-09-06  9:53     ` Wu, Feng
2016-08-31  3:56 ` [PATCH v3 2/6] VMX: Properly handle pi when all the assigned devices are removed Feng Wu
2016-09-01  8:21   ` Jan Beulich
2016-09-01  9:22     ` Wu, Feng
2016-09-01 10:23       ` Jan Beulich
2016-09-01 13:12         ` Wu, Feng
2016-09-06  8:58   ` Dario Faggioli
2016-08-31  3:56 ` [PATCH v3 3/6] VMX: Cleanup PI per-cpu blocking list when vcpu is destroyed Feng Wu
2016-09-06  9:21   ` Dario Faggioli [this message]
2016-09-06 23:27     ` Wu, Feng
2016-08-31  3:56 ` [PATCH v3 4/6] Pause/Unpause the domain before/after assigning PI hooks Feng Wu
2016-09-01  8:29   ` Jan Beulich
2016-09-02  1:46     ` Wu, Feng
2016-09-02  7:04       ` Jan Beulich
2016-09-02  7:31         ` Wu, Feng
2016-09-02  8:16           ` Jan Beulich
2016-09-02  8:40             ` Wu, Feng
2016-09-02  9:25               ` Jan Beulich
2016-09-02 10:30                 ` Wu, Feng
2016-09-02 10:45                   ` Jan Beulich
2016-09-02 13:15                     ` Wu, Feng
2016-09-02 13:54                       ` Jan Beulich
2016-09-05  3:11                         ` Wu, Feng
2016-09-05  9:27                           ` Jan Beulich
2016-09-14  2:23                           ` Wu, Feng
2016-09-14  8:46                             ` Jan Beulich
2016-09-14 14:51                             ` Dario Faggioli
2016-09-18  8:37                               ` Wu, Feng
2016-09-19 23:12                                 ` Dario Faggioli
2016-09-20  0:48                                   ` Wu, Feng
2016-09-20  7:31                                   ` Jan Beulich
2016-09-20  7:53                                     ` Wu, Feng
2016-09-20  8:13                                     ` Dario Faggioli
2016-09-20  8:18                                       ` Wu, Feng
2016-09-23 14:19                       ` Jan Beulich
2016-09-26  2:53                         ` Wu, Feng
2016-08-31  3:56 ` [PATCH v3 5/6] VT-d: No need to set irq affinity for posted format IRTE Feng Wu
2016-09-01  8:38   ` Jan Beulich
2016-09-02  1:58     ` Wu, Feng
2016-08-31  3:56 ` [PATCH v3 6/6] VMX: Fixup PI descritpor when cpu is offline Feng Wu
2016-09-01  8:48   ` Jan Beulich
2016-09-02  3:25     ` Wu, Feng
2016-09-02  7:08       ` 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=1473153693.19612.103.camel@citrix.com \
    --to=dario.faggioli@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=feng.wu@intel.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xen.org \
    /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.