xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: "Wu, Feng" <feng.wu@intel.com>, Jan Beulich <JBeulich@suse.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Dario Faggioli <dario.faggioli@citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v11 1/2] vmx: VT-d posted-interrupt core logic handling
Date: Wed, 10 Feb 2016 12:25:17 +0000	[thread overview]
Message-ID: <56BB2C2D.20402@citrix.com> (raw)
In-Reply-To: <E959C4978C3B6342920538CF579893F00C2F0AAB@SHSMSX104.ccr.corp.intel.com>

On 02/02/16 04:48, Wu, Feng wrote:
>>>>> +static void vmx_pi_do_resume(struct vcpu *v)
>>>>> +{
>>>>> +    unsigned long flags;
>>>>> +    spinlock_t *pi_block_list_lock;
>>>>> +    struct pi_desc *pi_desc = &v->arch.hvm_vmx.pi_desc;
>>>>> +
>>>>> +    ASSERT(!test_bit(_VPF_blocked, &v->pause_flags));
>>>>> +
>>>>> +    /*
>>>>> +     * 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.
>>>>> +     */
>>>>> +    if ( pi_desc->nv != posted_intr_vector )
>>>>> +        write_atomic(&pi_desc->nv, posted_intr_vector);
>>>>
>>>> Perhaps this was discussed before, but I don't recall and now
>>>> wonder - why inside an if()? This is a simple memory write on
>>>> x86.
>>>
>>> The initial purpose is that if NV is already equal to 'posted_intr_vector',
>>> we can save the following atomically write operation. There are some
>>> volatile stuff and barriers in write_atomic().
>>
>> But what does the final generated code look like? As I said, I'm
>> sure it's just a single MOV. And putting a conditional around it will
>> likely make things slower rather than faster.
> 
> Looking at the implementation of wirte_atomic(), it has volatile key
> word barrier inside, if you think this is not a big deal, I am fine to
> remove the check.

Oh, right -- so set_sn and clear_sn use the set/clear bits, which are
atomic read-modify-write, which we'd like to avoid on the vmexit/vmentry
paths (which is why we have the scheduler hooks); but this is just a
straight up write, so it's OK.

>>>>> --- a/xen/drivers/passthrough/vtd/iommu.c
>>>>> +++ b/xen/drivers/passthrough/vtd/iommu.c
>>>>> @@ -2293,6 +2293,8 @@ static int reassign_device_ownership(
>>>>>          pdev->domain = target;
>>>>>      }
>>>>>
>>>>> +    vmx_pi_hooks_reassign(source, target);
>>>>> +
>>>>>      return ret;
>>>>>  }
>>>>
>>>> I think you need to clear source's hooks here, but target's need to
>>>> get set ahead of the actual assignment.
>>>
>>> I think this is the place where the device is moved from
>>> &source->arch.pdev_list to &target->arch.pdev_list, if that is the
>>> case, we should clear source and set target here, right?
>>
>> No - target needs to be ready to deal with events from the device
>> _before_ the device actually gets assigned to it.
> 
> I still don't get your point. I still think this is the place where the device
> is being got assigned. Or maybe you can share more info about the
> place "_before_ the device actually gets assigned to it " ?

What happens if a device generates a PI interrupt *immediately* after
domain_context_mapping(), but before calling vmx_pi_hooks_reassign()?

 -George

  parent reply	other threads:[~2016-02-10 12:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28  5:12 [PATCH v11 0/2] Add VT-d Posted-Interrupts support Feng Wu
2016-01-28  5:12 ` [PATCH v11 1/2] vmx: VT-d posted-interrupt core logic handling Feng Wu
2016-01-28 16:38   ` Jan Beulich
2016-01-29  1:53     ` Wu, Feng
2016-01-29  9:31       ` Jan Beulich
2016-02-02  4:48         ` Wu, Feng
2016-02-02  9:53           ` Jan Beulich
2016-02-16  6:33             ` Wu, Feng
2016-02-16 10:23               ` Jan Beulich
2016-02-10 12:25           ` George Dunlap [this message]
2016-02-16  5:54             ` Wu, Feng
2016-02-10 12:35   ` George Dunlap
2016-02-16  6:00     ` Wu, Feng
2016-01-28  5:12 ` [PATCH v11 2/2] Add a command line parameter for VT-d posted-interrupts Feng Wu

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=56BB2C2D.20402@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=feng.wu@intel.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=keir@xen.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).