From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: The scenario of hypercall_preempt_check() Date: Sat, 1 Jun 2013 12:05:53 +0100 Message-ID: <51A9D591.5060009@citrix.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1731923675211863848==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xinxin Jin Cc: "Xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --===============1731923675211863848== Content-Type: multipart/alternative; boundary="------------040209070703020708060208" --------------040209070703020708060208 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On 01/06/2013 10:30, Xinxin Jin wrote: > Hi all, > > I found there is hypercall preemption check in some hypercall handlers: > > #define hypercall_preempt_check() (unlikely( \ > softirq_pending(smp_processor_id()) | \ > local_events_need_delivery() \ > )) > > Generally speaking, if there is pending softirq or upcall events, the > hypercall handler will exit and try to re-execute next time. I have > two confusions on hypercall preemption: > (1) Why pending softirq or upcall events can affect hypercall's > continuation ? > (2) When do we need to do hypercall_preempt_check()? For example, > do_mmuext_op() has this check but many other hypercall handles don't > do the check. How to judge where to appy preemption check? > > A lot of thanks, > > Xinxin The whole point of hypercall preemeption is to prevent long running hypercalls starve VCPUs of events. Pending softirqs means that a Xen timer has expired and needs to run, while local events will be to the vcpu making the hypercall. Judging when to use preeemption is harder. First of all, work out whether it is possible/safe to split the work of the hypercall up across continuations. Most hypercalls cant, but are fairly short. On the other hand, any hypercall which is looping over guest arrays is a good candidate for preemption. ~Andrew --------------040209070703020708060208 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit
On 01/06/2013 10:30, Xinxin Jin wrote:
Hi all,

I found there is hypercall preemption check in some hypercall handlers: 

#define hypercall_preempt_check() (unlikely(    \
        softirq_pending(smp_processor_id()) |   \
        local_events_need_delivery()            \
    ))

Generally speaking, if there is pending softirq or upcall events, the hypercall handler will exit and try to re-execute next time. I have two confusions on hypercall preemption:
(1) Why pending softirq or upcall events can affect hypercall's continuation ? 
(2) When do we need to do hypercall_preempt_check()? For example, do_mmuext_op() has this check but many other hypercall handles don't do the check. How to judge where to appy preemption check?

A lot of thanks, 

Xinxin

The whole point of hypercall preemeption is to prevent long running hypercalls starve VCPUs of events.  Pending softirqs means that a Xen timer has expired and needs to run, while local events will be to the vcpu making the hypercall.

Judging when to use preeemption is harder.  First of all, work out whether it is possible/safe to split the work of the hypercall up across continuations.  Most hypercalls cant, but are fairly short.  On the other hand, any hypercall which is looping over guest arrays is a good candidate for preemption.

~Andrew
--------------040209070703020708060208-- --===============1731923675211863848== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============1731923675211863848==--