From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 1/2] common: make hypercall preemption checks consistent Date: Tue, 4 Mar 2014 11:29:42 +0000 Message-ID: <5315B926.6030306@citrix.com> References: <5315C5370200007800120CE4@nat28.tlf.novell.com> <5315C6160200007800120CF3@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5824097382804200153==" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WKnXe-0000Em-W0 for xen-devel@lists.xenproject.org; Tue, 04 Mar 2014 11:29:47 +0000 In-Reply-To: <5315C6160200007800120CF3@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============5824097382804200153== Content-Type: multipart/alternative; boundary="------------090601050703040805030706" --------------090601050703040805030706 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 04/03/14 11:24, Jan Beulich wrote: > - never preempt on the first iteration (ensure forward progress) > - do cheap checks first > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/common/memory.c > +++ b/xen/common/memory.c > @@ -63,7 +63,7 @@ static void increase_reservation(struct > > for ( i = a->nr_done; i < a->nr_extents; i++ ) > { > - if ( hypercall_preempt_check() ) > + if ( i != a->nr_done && hypercall_preempt_check() ) > { > a->preempted = 1; > goto out; > @@ -109,7 +109,7 @@ static void populate_physmap(struct memo > > for ( i = a->nr_done; i < a->nr_extents; i++ ) > { > - if ( hypercall_preempt_check() ) > + if ( i != a->nr_done && hypercall_preempt_check() ) > { > a->preempted = 1; > goto out; > @@ -268,7 +268,7 @@ static void decrease_reservation(struct > > for ( i = a->nr_done; i < a->nr_extents; i++ ) > { > - if ( hypercall_preempt_check() && i != a->nr_done ) > + if ( i != a->nr_done && hypercall_preempt_check() ) > { > a->preempted = 1; > goto out; > @@ -398,7 +398,8 @@ static long memory_exchange(XEN_GUEST_HA > i < (exch.in.nr_extents >> in_chunk_order); > i++ ) > { > - if ( hypercall_preempt_check() ) > + if ( i != (exch.nr_exchanged >> in_chunk_order) && > + hypercall_preempt_check() ) > { > exch.nr_exchanged = i << in_chunk_order; > rcu_unlock_domain(d); > --- a/xen/common/multicall.c > +++ b/xen/common/multicall.c > @@ -52,7 +52,7 @@ do_multicall( > > for ( i = 0; !rc && i < nr_calls; i++ ) > { > - if ( hypercall_preempt_check() ) > + if ( i && hypercall_preempt_check() ) > goto preempted; > > if ( unlikely(__copy_from_guest(&mcs->call, call_list, 1)) ) > --- a/xen/drivers/char/console.c > +++ b/xen/drivers/char/console.c > @@ -375,12 +375,12 @@ static DECLARE_SOFTIRQ_TASKLET(notify_do > static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count) > { > char kbuf[128]; > - int kcount; > + int kcount = 0; > struct domain *cd = current->domain; > > while ( count > 0 ) > { > - if ( hypercall_preempt_check() ) > + if ( kcount && hypercall_preempt_check() ) > return hypercall_create_continuation( > __HYPERVISOR_console_io, "iih", > CONSOLEIO_write, count, buffer); > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------090601050703040805030706 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 04/03/14 11:24, Jan Beulich wrote:
- never preempt on the first iteration (ensure forward progress)
- do cheap checks first

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -63,7 +63,7 @@ static void increase_reservation(struct 
 
     for ( i = a->nr_done; i < a->nr_extents; i++ )
     {
-        if ( hypercall_preempt_check() )
+        if ( i != a->nr_done && hypercall_preempt_check() )
         {
             a->preempted = 1;
             goto out;
@@ -109,7 +109,7 @@ static void populate_physmap(struct memo
 
     for ( i = a->nr_done; i < a->nr_extents; i++ )
     {
-        if ( hypercall_preempt_check() )
+        if ( i != a->nr_done && hypercall_preempt_check() )
         {
             a->preempted = 1;
             goto out;
@@ -268,7 +268,7 @@ static void decrease_reservation(struct 
 
     for ( i = a->nr_done; i < a->nr_extents; i++ )
     {
-        if ( hypercall_preempt_check() && i != a->nr_done )
+        if ( i != a->nr_done && hypercall_preempt_check() )
         {
             a->preempted = 1;
             goto out;
@@ -398,7 +398,8 @@ static long memory_exchange(XEN_GUEST_HA
           i < (exch.in.nr_extents >> in_chunk_order);
           i++ )
     {
-        if ( hypercall_preempt_check() )
+        if ( i != (exch.nr_exchanged >> in_chunk_order) &&
+             hypercall_preempt_check() )
         {
             exch.nr_exchanged = i << in_chunk_order;
             rcu_unlock_domain(d);
--- a/xen/common/multicall.c
+++ b/xen/common/multicall.c
@@ -52,7 +52,7 @@ do_multicall(
 
     for ( i = 0; !rc && i < nr_calls; i++ )
     {
-        if ( hypercall_preempt_check() )
+        if ( i && hypercall_preempt_check() )
             goto preempted;
 
         if ( unlikely(__copy_from_guest(&mcs->call, call_list, 1)) )
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -375,12 +375,12 @@ static DECLARE_SOFTIRQ_TASKLET(notify_do
 static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)
 {
     char kbuf[128];
-    int kcount;
+    int kcount = 0;
     struct domain *cd = current->domain;
 
     while ( count > 0 )
     {
-        if ( hypercall_preempt_check() )
+        if ( kcount && hypercall_preempt_check() )
             return hypercall_create_continuation(
                 __HYPERVISOR_console_io, "iih",
                 CONSOLEIO_write, count, buffer);





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

--------------090601050703040805030706-- --===============5824097382804200153== 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 --===============5824097382804200153==--