From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH 2/2] x86: make hypercall preemption checks consistent
Date: Tue, 4 Mar 2014 11:35:46 +0000 [thread overview]
Message-ID: <5315BA92.8080902@citrix.com> (raw)
In-Reply-To: <5315C65E0200007800120CF7@nat28.tlf.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 5052 bytes --]
On 04/03/14 11:26, Jan Beulich wrote:
> - never preempt on the first iteration (ensure forward progress)
> - never preempt on the last iteration (pointless/wasteful)
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -2934,7 +2934,7 @@ long do_mmuext_op(
>
> for ( i = 0; i < count; i++ )
> {
> - if ( curr->arch.old_guest_table || hypercall_preempt_check() )
> + if ( curr->arch.old_guest_table || (i && hypercall_preempt_check()) )
> {
> rc = -EAGAIN;
> break;
> @@ -3481,7 +3481,7 @@ long do_mmu_update(
>
> for ( i = 0; i < count; i++ )
> {
> - if ( curr->arch.old_guest_table || hypercall_preempt_check() )
> + if ( curr->arch.old_guest_table || (i && hypercall_preempt_check()) )
> {
> rc = -EAGAIN;
> break;
> --- a/xen/arch/x86/mm/hap/hap.c
> +++ b/xen/arch/x86/mm/hap/hap.c
> @@ -326,7 +326,7 @@ hap_set_allocation(struct domain *d, uns
> else
> pages -= d->arch.paging.hap.p2m_pages;
>
> - while ( d->arch.paging.hap.total_pages != pages )
> + for ( ; ; )
> {
> if ( d->arch.paging.hap.total_pages < pages )
> {
> @@ -355,6 +355,8 @@ hap_set_allocation(struct domain *d, uns
> d->arch.paging.hap.total_pages--;
> free_domheap_page(pg);
> }
> + else
> + break;
>
> /* Check to see if we need to yield and try again */
> if ( preempted && hypercall_preempt_check() )
> --- a/xen/arch/x86/mm/p2m-pod.c
> +++ b/xen/arch/x86/mm/p2m-pod.c
> @@ -242,7 +242,8 @@ p2m_pod_set_cache_target(struct p2m_doma
>
> p2m_pod_cache_add(p2m, page, order);
>
> - if ( hypercall_preempt_check() && preemptible )
> + if ( preemptible && pod_target != p2m->pod.count &&
> + hypercall_preempt_check() )
> {
> ret = -EAGAIN;
> goto out;
> @@ -286,7 +287,8 @@ p2m_pod_set_cache_target(struct p2m_doma
>
> put_page(page+i);
>
> - if ( hypercall_preempt_check() && preemptible )
> + if ( preemptible && pod_target != p2m->pod.count &&
> + hypercall_preempt_check() )
> {
> ret = -EAGAIN;
> goto out;
> --- a/xen/arch/x86/mm/shadow/common.c
> +++ b/xen/arch/x86/mm/shadow/common.c
> @@ -1672,7 +1672,7 @@ static unsigned int sh_set_allocation(st
> SHADOW_PRINTK("current %i target %i\n",
> d->arch.paging.shadow.total_pages, pages);
>
> - while ( d->arch.paging.shadow.total_pages != pages )
> + for ( ; ; )
> {
> if ( d->arch.paging.shadow.total_pages < pages )
> {
> @@ -1707,6 +1707,8 @@ static unsigned int sh_set_allocation(st
> d->arch.paging.shadow.total_pages--;
> free_domheap_page(sp);
> }
> + else
> + break;
>
> /* Check to see if we need to yield and try again */
> if ( preempted && hypercall_preempt_check() )
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -3596,13 +3596,6 @@ long do_set_trap_table(XEN_GUEST_HANDLE_
>
> for ( ; ; )
> {
> - if ( hypercall_preempt_check() )
> - {
> - rc = hypercall_create_continuation(
> - __HYPERVISOR_set_trap_table, "h", traps);
> - break;
> - }
> -
> if ( copy_from_guest(&cur, traps, 1) )
> {
> rc = -EFAULT;
> @@ -3623,6 +3616,13 @@ long do_set_trap_table(XEN_GUEST_HANDLE_
> init_int80_direct_trap(curr);
>
> guest_handle_add_offset(traps, 1);
> +
> + if ( hypercall_preempt_check() )
> + {
> + rc = hypercall_create_continuation(
> + __HYPERVISOR_set_trap_table, "h", traps);
> + break;
> + }
> }
>
> return rc;
> --- a/xen/arch/x86/x86_64/compat/traps.c
> +++ b/xen/arch/x86/x86_64/compat/traps.c
> @@ -329,13 +329,6 @@ int compat_set_trap_table(XEN_GUEST_HAND
>
> for ( ; ; )
> {
> - if ( hypercall_preempt_check() )
> - {
> - rc = hypercall_create_continuation(
> - __HYPERVISOR_set_trap_table, "h", traps);
> - break;
> - }
> -
> if ( copy_from_guest(&cur, traps, 1) )
> {
> rc = -EFAULT;
> @@ -353,6 +346,13 @@ int compat_set_trap_table(XEN_GUEST_HAND
> init_int80_direct_trap(current);
>
> guest_handle_add_offset(traps, 1);
> +
> + if ( hypercall_preempt_check() )
> + {
> + rc = hypercall_create_continuation(
> + __HYPERVISOR_set_trap_table, "h", traps);
> + break;
> + }
> }
>
> return rc;
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 5825 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-03-04 11:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 11:21 [PATCH 0/2] make hypercall preemption checks consistent Jan Beulich
2014-03-04 11:24 ` [PATCH 1/2] common: " Jan Beulich
2014-03-04 11:29 ` Andrew Cooper
2014-03-04 11:26 ` [PATCH 2/2] x86: " Jan Beulich
2014-03-04 11:35 ` Andrew Cooper [this message]
2014-03-04 11:30 ` [PATCH 0/2] " Jan Beulich
2014-03-11 11:38 ` Ian Campbell
2014-03-04 11:46 ` Tim Deegan
2014-03-04 11:52 ` Andrew Cooper
2014-03-04 12:00 ` Jan Beulich
2014-03-04 12:10 ` David Vrabel
2014-03-04 13:06 ` Jan Beulich
2014-03-04 14:07 ` David Vrabel
2014-03-12 9:35 ` Ping: " Jan Beulich
2014-03-13 10:26 ` Keir Fraser
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=5315BA92.8080902@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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.