All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: Stephan Diestelhorst <stephan.diestelhorst@amd.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	"Przywara, Andre" <Andre.Przywara@amd.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Keir Fraser <keir@xen.org>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: Hypervisor crash(!) on xl cpupool-numa-split
Date: Thu, 03 Feb 2011 10:18:16 +0100	[thread overview]
Message-ID: <4D4A72D8.3020502@ts.fujitsu.com> (raw)
In-Reply-To: <4D4A43B7.5040707@ts.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

Andre, Stephan,

could you give the attached patch a try?
It moves the cpu assigning/unassigning into a tasklet always executed on the
cpu to be moved. This should avoid critical races.

Regarding Stephans rant:
You should be aware that the main critical sections are only in the tasklets.
The locking in the main routines is needed only to avoid the cpupool to be
destroyed in between.

I'm not sure whether the master_ticker patch is still needed. It seems to
break something, as my machine hung up after several 100 cpu moves (without
the new patch). I'm still investigating this problem.


Juergen

-- 
Juergen Gross                 Principal Developer Operating Systems
TSP ES&S SWE OS6                       Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions              e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28                           Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html

[-- Attachment #2: cpupool-idle.patch --]
[-- Type: text/x-patch, Size: 4879 bytes --]

diff -r 4bdb78db22b6 xen/common/cpupool.c
--- a/xen/common/cpupool.c	Wed Feb 02 17:06:36 2011 +0000
+++ b/xen/common/cpupool.c	Thu Feb 03 10:09:53 2011 +0100
@@ -217,14 +217,30 @@ static int cpupool_assign_cpu_locked(str
     return 0;
 }
 
+static long cpupool_assign_cpu_helper(void *info)
+{
+    int cpu = cpupool_moving_cpu;
+    long ret;
+
+    cpupool_dprintk("cpupool_assign_cpu(pool=%d,cpu=%d) ret %ld\n",
+                    cpupool_cpu_moving->cpupool_id, cpu, ret);
+    BUG_ON(!is_idle_vcpu(current));
+    BUG_ON(cpu != smp_processor_id());
+    spin_lock(&cpupool_lock);
+    ret = cpupool_assign_cpu_locked(cpupool_cpu_moving, cpu);
+    spin_unlock(&cpupool_lock);
+    return ret;
+}
+
 static long cpupool_unassign_cpu_helper(void *info)
 {
     int cpu = cpupool_moving_cpu;
     long ret;
 
     cpupool_dprintk("cpupool_unassign_cpu(pool=%d,cpu=%d) ret %ld\n",
-                    cpupool_id, cpu, ret);
-
+                    cpupool_cpu_moving->cpupool_id, cpu, ret);
+    BUG_ON(!is_idle_vcpu(current));
+    BUG_ON(cpu != smp_processor_id());
     spin_lock(&cpupool_lock);
     ret = cpu_disable_scheduler(cpu);
     cpu_set(cpu, cpupool_free_cpus);
@@ -241,9 +257,51 @@ static long cpupool_unassign_cpu_helper(
 }
 
 /*
+ * assign a specific cpu to a cpupool
+ * we must be sure to run on the cpu to be assigned in idle! to achieve this
+ * the main functionality is performed via continue_hypercall_on_cpu on the
+ * specific cpu.
+ * possible failures:
+ * - cpu not free
+ * - cpu just being unplugged
+ */
+int cpupool_assign_cpu(struct cpupool *c, unsigned int cpu)
+{
+    int ret;
+
+    cpupool_dprintk("cpupool_assign_cpu(pool=%d,cpu=%d)\n",
+                    c->cpupool_id, cpu);
+
+    spin_lock(&cpupool_lock);
+    ret = -EBUSY;
+    if ( (cpupool_moving_cpu != -1) && (cpu != cpupool_moving_cpu) )
+        goto out;
+    if ( cpu_isset(cpu, cpupool_locked_cpus) )
+        goto out;
+
+    ret = 0;
+    if ( !cpu_isset(cpu, cpupool_free_cpus) && (cpu != cpupool_moving_cpu) )
+        goto out;
+
+    cpupool_moving_cpu = cpu;
+    atomic_inc(&c->refcnt);
+    cpupool_cpu_moving = c;
+    cpu_clear(cpu, c->cpu_valid);
+    spin_unlock(&cpupool_lock);
+
+    return continue_hypercall_on_cpu(cpu, cpupool_assign_cpu_helper, c);
+
+out:
+    spin_unlock(&cpupool_lock);
+    cpupool_dprintk("cpupool_assign_cpu(pool=%d,cpu=%d) ret %d\n",
+                    cpupool_id, cpu, ret);
+    return ret;
+}
+
+/*
  * unassign a specific cpu from a cpupool
- * we must be sure not to run on the cpu to be unassigned! to achieve this
- * the main functionality is performed via continue_hypercall_on_cpu on a
+ * we must be sure to run on the cpu to be unassigned in idle! to achieve this
+ * the main functionality is performed via continue_hypercall_on_cpu on the
  * specific cpu.
  * if the cpu to be removed is the last one of the cpupool no active domain
  * must be bound to the cpupool. dying domains are moved to cpupool0 as they
@@ -254,7 +312,6 @@ static long cpupool_unassign_cpu_helper(
  */
 int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
 {
-    int work_cpu;
     int ret;
     struct domain *d;
 
@@ -302,14 +359,7 @@ int cpupool_unassign_cpu(struct cpupool 
     cpu_clear(cpu, c->cpu_valid);
     spin_unlock(&cpupool_lock);
 
-    work_cpu = smp_processor_id();
-    if ( work_cpu == cpu )
-    {
-        work_cpu = first_cpu(cpupool0->cpu_valid);
-        if ( work_cpu == cpu )
-            work_cpu = next_cpu(cpu, cpupool0->cpu_valid);
-    }
-    return continue_hypercall_on_cpu(work_cpu, cpupool_unassign_cpu_helper, c);
+    return continue_hypercall_on_cpu(cpu, cpupool_unassign_cpu_helper, c);
 
 out:
     spin_unlock(&cpupool_lock);
@@ -455,27 +505,15 @@ int cpupool_do_sysctl(struct xen_sysctl_
     {
         unsigned cpu;
 
+        c = __cpupool_get_by_id(op->cpupool_id, 0);
+        ret = -ENOENT;
+        if ( c == NULL )
+            break;
         cpu = op->cpu;
-        cpupool_dprintk("cpupool_assign_cpu(pool=%d,cpu=%d)\n",
-                        op->cpupool_id, cpu);
-        spin_lock(&cpupool_lock);
         if ( cpu == XEN_SYSCTL_CPUPOOL_PAR_ANY )
             cpu = first_cpu(cpupool_free_cpus);
-        ret = -EINVAL;
-        if ( cpu >= NR_CPUS )
-            goto addcpu_out;
-        ret = -EBUSY;
-        if ( !cpu_isset(cpu, cpupool_free_cpus) )
-            goto addcpu_out;
-        c = cpupool_find_by_id(op->cpupool_id, 0);
-        ret = -ENOENT;
-        if ( c == NULL )
-            goto addcpu_out;
-        ret = cpupool_assign_cpu_locked(c, cpu);
-    addcpu_out:
-        spin_unlock(&cpupool_lock);
-        cpupool_dprintk("cpupool_assign_cpu(pool=%d,cpu=%d) ret %d\n",
-                        op->cpupool_id, cpu, ret);
+        ret = (cpu < NR_CPUS) ? cpupool_assign_cpu(c, cpu) : -EINVAL;
+        cpupool_put(c);
     }
     break;
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2011-02-03  9:18 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 23:18 Hypervisor crash(!) on xl cpupool-numa-split Andre Przywara
2011-01-28  6:47 ` Juergen Gross
2011-01-28 11:07   ` Andre Przywara
2011-01-28 11:44     ` Juergen Gross
2011-01-28 13:14       ` Andre Przywara
2011-01-31  7:04         ` Juergen Gross
2011-01-31 14:59           ` Andre Przywara
2011-01-31 15:28             ` George Dunlap
2011-02-01 16:32               ` Andre Przywara
2011-02-02  6:27                 ` Juergen Gross
2011-02-02  8:49                   ` Juergen Gross
2011-02-02 10:05                     ` Juergen Gross
2011-02-02 10:59                       ` Andre Przywara
2011-02-02 14:39                 ` Stephan Diestelhorst
2011-02-02 15:14                   ` Juergen Gross
2011-02-02 16:01                     ` Stephan Diestelhorst
2011-02-03  5:57                       ` Juergen Gross
2011-02-03  9:18                         ` Juergen Gross [this message]
2011-02-04 14:09                           ` Andre Przywara
2011-02-07 12:38                             ` Andre Przywara
2011-02-07 13:32                               ` Juergen Gross
2011-02-07 15:55                                 ` George Dunlap
2011-02-08  5:43                                   ` Juergen Gross
2011-02-08 12:08                                     ` George Dunlap
2011-02-08 12:14                                       ` George Dunlap
2011-02-08 16:33                                         ` Andre Przywara
2011-02-09 12:27                                           ` George Dunlap
2011-02-09 12:27                                             ` George Dunlap
2011-02-09 13:04                                               ` Juergen Gross
2011-02-09 13:39                                                 ` Andre Przywara
2011-02-09 13:51                                               ` Andre Przywara
2011-02-09 14:21                                                 ` Juergen Gross
2011-02-10  6:42                                                   ` Juergen Gross
2011-02-10  9:25                                                     ` Andre Przywara
2011-02-10 14:18                                                       ` Andre Przywara
2011-02-11  6:17                                                         ` Juergen Gross
2011-02-11  7:39                                                           ` Andre Przywara
2011-02-14 17:57                                                             ` George Dunlap
2011-02-15  7:22                                                               ` Juergen Gross
2011-02-16  9:47                                                                 ` Juergen Gross
2011-02-16 13:54                                                                   ` George Dunlap
     [not found]                                                                     ` <4D6237C6.1050206@amd.c om>
2011-02-16 14:11                                                                     ` Juergen Gross
2011-02-16 14:28                                                                       ` Juergen Gross
2011-02-17  0:05                                                                       ` André Przywara
2011-02-17  7:05                                                                     ` Juergen Gross
2011-02-17  9:11                                                                       ` Juergen Gross
2011-02-21 10:00                                                                     ` Andre Przywara
2011-02-21 13:19                                                                       ` Juergen Gross
2011-02-21 14:45                                                                         ` Andre Przywara
2011-02-21 14:50                                                                           ` Juergen Gross
2011-02-08 12:23                                       ` Juergen Gross
2011-01-28 11:13   ` George Dunlap
2011-01-28 13:05     ` Andre Przywara

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=4D4A72D8.3020502@ts.fujitsu.com \
    --to=juergen.gross@ts.fujitsu.com \
    --cc=Andre.Przywara@amd.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=stephan.diestelhorst@amd.com \
    --cc=xen-devel@lists.xensource.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.