xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xen.org
Cc: Juergen Gross <jgross@suse.com>,
	Dario Faggioli <dario.faggioli@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v3 1/6] xen, cpupool: correct error handling when removing cpu from cpupool
Date: Thu,  3 Mar 2016 17:48:45 +0100	[thread overview]
Message-ID: <1457023730-10997-2-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1457023730-10997-1-git-send-email-jgross@suse.com>

When schedule_cpu_switch() called from cpupool_unassign_cpu_helper()
returns an error, the domlist_read_lock isn't released again.

As cpu_disable_scheduler() might have changed affinity of some
domains domain_update_node_affinity() must be called for all domains
in the cpupool even in error case.

Even if looking weird it is okay to let the to be removed cpu set in
cpupool_free_cpus in case of an error returned by
cpu_disable_scheduler(). Add a comment explaining the reason for this.

Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/common/cpupool.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c
index 8e7b723..d0189f8 100644
--- a/xen/common/cpupool.c
+++ b/xen/common/cpupool.c
@@ -312,17 +312,25 @@ static long cpupool_unassign_cpu_helper(void *info)
     rcu_read_lock(&domlist_read_lock);
     ret = cpu_disable_scheduler(cpu);
     cpumask_set_cpu(cpu, &cpupool_free_cpus);
+
+    /*
+     * cpu_disable_scheduler() returning an error doesn't require resetting
+     * cpupool_free_cpus' cpu bit. All error cases should be of temporary
+     * nature and tools will retry the operation. Even if the number of
+     * retries may be limited, the in-between state can easily be repaired
+     * by adding the cpu to the cpupool again.
+     */
     if ( !ret )
     {
         ret = schedule_cpu_switch(cpu, NULL);
         if ( ret )
-        {
             cpumask_clear_cpu(cpu, &cpupool_free_cpus);
-            goto out;
+        else
+        {
+            cpupool_moving_cpu = -1;
+            cpupool_put(cpupool_cpu_moving);
+            cpupool_cpu_moving = NULL;
         }
-        cpupool_moving_cpu = -1;
-        cpupool_put(cpupool_cpu_moving);
-        cpupool_cpu_moving = NULL;
     }
 
     for_each_domain_in_cpupool(d, c)
-- 
2.6.2


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

  reply	other threads:[~2016-03-03 16:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 16:48 [PATCH v3 0/6] add hypercall option to temporarily pin a vcpu Juergen Gross
2016-03-03 16:48 ` Juergen Gross [this message]
2016-03-04  9:42   ` [PATCH v3 1/6] xen, cpupool: correct error handling when removing cpu from cpupool Jan Beulich
     [not found]   ` <56D9668602000078000D9400@suse.com>
2016-03-04  9:54     ` Juergen Gross
2016-03-04 10:03       ` Jan Beulich
2016-03-08 10:46   ` Dario Faggioli
2016-03-03 16:48 ` [PATCH v3 2/6] xen: add hypercall option to override and restore vcpu affinity Juergen Gross
2016-03-04  9:44   ` Jan Beulich
2016-03-08 11:45   ` Dario Faggioli
2016-03-03 16:48 ` [PATCH v3 3/6] xen: add force flag to xen_domctl_vcpuaffinity for undoing pin override Juergen Gross
2016-03-04  9:45   ` Jan Beulich
2016-03-03 16:48 ` [PATCH v3 4/6] libxc: do some retries in xc_cpupool_removecpu() for EBUSY case Juergen Gross
2016-03-08 13:16   ` Dario Faggioli
2016-03-08 16:12     ` Juergen Gross
2016-03-03 16:48 ` [PATCH v3 5/6] libxl: print message how to recover from xl cpupool-cpu-remove errors Juergen Gross
2016-03-08 13:18   ` Dario Faggioli
2016-03-08 15:58   ` Wei Liu
2016-03-03 16:48 ` [PATCH v3 6/6] libxl: add force option for xl vcpu-pin Juergen Gross
2016-03-08 13:29   ` Dario Faggioli
2016-03-08 15:58   ` Wei Liu
2016-03-08 16:11     ` Juergen Gross
2016-03-08 17:16   ` Dario Faggioli
2016-03-08 17:19     ` Juergen Gross

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=1457023730-10997-2-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=dario.faggioli@citrix.com \
    --cc=jbeulich@suse.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).