All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: "Xuquan (Quan Xu)" <xuquan8@huawei.com>
Cc: "yang.zhang.wz@gmail.com" <yang.zhang.wz@gmail.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"quan.xu0@gmail.com" <quan.xu0@gmail.com>,
	Jan Beulich <JBeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	"Nakajima, Jun" <jun.nakajima@intel.com>
Subject: Re: [PATCH] x86/apicv: enhance posted-interrupt processing
Date: Tue, 21 Feb 2017 05:54:38 +0800	[thread overview]
Message-ID: <20170220215438.GA19609@skl-2s3.sh.intel.com> (raw)
In-Reply-To: <E0A769A898ADB6449596C41F51EF62C6AE777E@SZXEMI506-MBX.china.huawei.com>

On Tue, Feb 21, 2017 at 04:11:53AM +0000, Xuquan (Quan Xu) wrote:
>On February 21, 2017 11:07 AM, Tian, Kevin wrote:
>>> From: Xuquan (Quan Xu) [mailto:xuquan8@huawei.com]
>>> Sent: Tuesday, February 21, 2017 10:49 AM
>>> >>Chao, __iiuc__, your question may be from the comments of
>>> >xen/arch/x86/hvm/vmx/vmx.c :: pi_notification_interrupt() ..
>>> >>IF VT-d PI is enabled,
>>> >>   VCPU_KICK_SOFTIRQ bit is set by '
>>> >>raise_softirq(VCPU_KICK_SOFTIRQ)',
>>> >at the end of pi_notification_interrupt()..
>>> >>Else
>>> >>  Is it possible for your case?
>>> >>
>>> >If vcpu is in root mode and is to do VM-entry, it has synced PIR to vIRR.
>>> >Now a interrupt (e.g. PMU_APIC_VECTOR) happens. Thus it goes
>>> >following the path
>>> >pmu_apic_interrupt->vpmu_do_interrupt->vlapic_set_irq(assume
>>> >it will inject a interrupt to current vcpu)
>>> >-> vmx_deliver_posted_intr( set one bit in PIR )->
>>> >-> __vmx_deliver_posted_interrupt
>>> >Assuming that there is no softirq pending, the code after change
>>> >doesn't generate a IPI for (cpu == smp_processor_id()). In this case,
>>> >this interrupt would not be injected to guest before this VM-entry.
>>> >Although there are many assumption in the explaination, I think it
>>> >may be possible.
>>> >
>>>
>>> So far, I agree to add VCPU_KICK_SOFTIRQ bit in a nice way..
>>> Even we have checked whether the vCPU is running or not at the
>>> beginning of __vmx_deliver_posted_interrupt(), we can't grantee the
>>> vcpu is still in guest mode at the point to call this IPI..
>>> as in an extreme case, at the point to call this IPI, all of vCPUs are
>>> in root-mode, the posted-interrupt won't be delivered..
>>
>>I don't understand of your concern of whether guest is in guest mode here.
>
>If the vCPUs are in root-mode, whatever we do we can't deliver posted interrupt
>Successfully.
>
>...
>
>>The purpose of this function is not to guarantee posted-interrupt is always
>>used (cannot unless you pause remote cpu). It's just a best effort.
>
>...
>
>the best effort, you mentioned here, __iiuc__, we will sync PIRR to vIRR
>before vmentry..
>
>if we don't set VCPU_KICK_SOFTIRQ bit, the pending interrupt in PIRR will be not synced to vIRR before vm-entry in time.
>In an extreme case, if there is only one interrupt pending interrupt in PIRR (no other caller to set VCPU_KICK_SOFTIRQ bit),
>The pending interrupt in PIRR will never be delivered to guest later..
>
>...
>
>> If target
>>vcpu is in root mode, then this IPI causes a real interrupt on remote cpu as
>>notification (then the handler pi_notification_interrupt you copied earlier
>>will jump in to help).
>>
>>
>...
>The posted_intr_vector handler is not always pi_notification_interrupt. If the vt-d PI is not enabled, the handler
>is event_check_interrupt..
>The VCPU_KICK_SOFTIRQ bit is set in  pi_notification_interrupt , but not event_check_interrupt..
>
OK. you are right. I think we can resolve it by replacing event_check_interrupt with pi_notification_interrupt.
A remote vcpu receives event check notification, the vcpu doesn't know where it is. Maybe it hasn't execute the code
that handles event, or it has already execute the code. So if the vcpu wants to handle the event, it's better to jump 
back to the code that handles event. I guess why the current event_check_interrupt doesn't set the softirq flag
is it assumes the flag has been set by the source vcpu ( by the line you remove ).

Also, for the case that the target vcpu is current vcpu, the vcpu also doesn't know about where it is.
It is better to set a softirq if there is no softirq.

Thanks,
Chao
>
>
>-I'd be very sorry if my description is still not clear..
>Quan

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

  reply	other threads:[~2017-02-20 21:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  9:37 [PATCH] x86/apicv: enhance posted-interrupt processing Xuquan (Quan Xu)
2017-02-17  8:49 ` Chao Gao
2017-02-17 16:32   ` Jan Beulich
2017-02-20 11:25     ` Xuquan (Quan Xu)
2017-02-20  8:24       ` Chao Gao
2017-02-21  2:49         ` Xuquan (Quan Xu)
2017-02-21  3:07           ` Tian, Kevin
2017-02-21  4:11             ` Xuquan (Quan Xu)
2017-02-20 21:54               ` Chao Gao [this message]
2017-02-21  6:19                 ` Xuquan (Quan Xu)
2017-02-21  9:08                   ` Jan Beulich
2017-02-21  9:44               ` Tian, Kevin
2017-02-23  9:28     ` Xuquan (Quan Xu)
2017-02-23  9:59       ` Jan Beulich
2017-02-23 10:53         ` Xuquan (Quan Xu)
2017-02-23 11:01           ` Jan Beulich
2017-02-23 11:55             ` Xuquan (Quan Xu)
2017-02-23  8:37               ` Chao Gao
2017-02-27  8:00                 ` Xuquan (Quan Xu)
2017-02-23 12:26               ` Jan Beulich
2017-02-24  8:02                 ` Xuquan (Quan Xu)
2017-02-24  8:20                   ` 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=20170220215438.GA19609@skl-2s3.sh.intel.com \
    --to=chao.gao@intel.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=quan.xu0@gmail.com \
    --cc=xen-devel@lists.xen.org \
    --cc=xuquan8@huawei.com \
    --cc=yang.zhang.wz@gmail.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.