Skip to contentSkip to conversation

qemu-xen: fix cpu hotplug

PATCH In review Stefano Stabellini 4 participants 9 messages Sep 2, 2010 – Sep 6, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-xen: fix cpu hotplug

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it.
This patch fixes both of them: a xenstore vcpu hotplug command is of the following form:

path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

xenstore.c +11 -9
index 6d24613..2c325ad 100644
@@ -680,9 +680,12 @@ void xenstore_parse_domain_config(int hvm_domid)
     }
 
     /* Set a watch for vcpu-set */
-    if (pasprintf(&buf, "/local/domain/%u/cpu", domid) != -1) {
-        xs_watch(xsh, buf, "vcpu-set");
-        fprintf(logfile, "Watching %s\n", buf);
+    for (i = 0; i < vcpus; i++) {
+        if (pasprintf(&buf, "/local/domain/%u/cpu/%u/availability",
+                    domid, i) != -1) {
+            xs_watch(xsh, buf, "vcpu-set");
+            fprintf(logfile, "Watching %s\n", buf);
+        }
     }
 
     /* no need for ifdef CONFIG_STUBDOM, since in the qemu case
@@ -970,15 +973,14 @@ void xenstore_record_dm_state(const char *state)
 static void xenstore_process_vcpu_set_event(char **vec)
 {
     char *act = NULL;
-    char *vcpustr, *node = vec[XS_WATCH_PATH];
-    unsigned int vcpu, len;
+    char *node = vec[XS_WATCH_PATH];
+    unsigned int vcpu, len, domid;
 
-    vcpustr = strstr(node, "cpu/");
-    if (!vcpustr) {
-        fprintf(stderr, "vcpu-set: watch node error.\n");
+    if (sscanf(node, "/local/domain/%u/cpu/%u/availability",
+                &domid, &vcpu) <= 0) {
+        fprintf(stderr, "vcpu-set: watch node error, path=%s\n", node);
         return;
     }
-    sscanf(vcpustr, "cpu/%u", &vcpu);
 
     act = xs_read(xsh, XBT_NULL, node, &len);
     if (!act) {
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: fix cpu hotplug"):

Quoted 4 lines

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it. This patch fixes both of them:

Thanks. So it seems you're saying it's completely broken in xen-unstable.

I have CC'd a bunch of Intel folks who were doing some other work on cpu hotplug. They were dealing with a race when multiple CPUs were added at once.

So I think there must be some confusion. Perhaps xl and xend have different ideas about what the xenstore syntax is for these operations ?

Jinsong Liu et al: would you care to comment ? Particularly about this:

Quoted 3 lines

A xenstore vcpu hotplug command is of the following form:
path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

That doesn't seem to match up with what's in xend, which seems to write "cpu_avail" in the vm tree.

Thanks,
Ian.

#2 lore raw
Quoted 9 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: fix cpu hotplug"):

Quoted 4 lines

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it. This patch fixes both of them:

Thanks. So it seems you're saying it's completely broken in xen-unstable.

Stabellini, I read your attached patch, it's OK.
In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

However, we finally didn't use this scheme. We watch 'common' node instead:
/local/domain/xx/cpu
in this way, only 1 watch point need.
Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Quoted 5 lines

I have CC'd a bunch of Intel folks who were doing some other work on cpu hotplug. They were dealing with a race when multiple CPUs were added at once.

Quoted 10 lines

So I think there must be some confusion. Perhaps xl and xend have different ideas about what the xenstore syntax is for these operations ?

Jinsong Liu et al: would you care to comment ? Particularly about this:

Quoted 3 lines

A xenstore vcpu hotplug command is of the following form:
path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

Yes, I think there must be some confusion.
Currently 'xm vcpu-set' command works fine with both PV and HVM vcpu hotplug.

Stabellini/Jackson, would your please tell me what xl recently happened for vcpu hotplug? is there any different ideas xl and xend about xenstore syntax?
(Each time 'xm vcpu-set' executed, xend will write all xenstore cpu node status)

Quoted 6 lines

That doesn't seem to match up with what's in xend, which seems to write "cpu_avail" in the vm tree.

Thanks,
Ian.

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it.
This patch fixes both of them: a xenstore vcpu hotplug command is of the following form:

path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

xenstore.c +11 -9
index 6d24613..2c325ad 100644
@@ -680,9 +680,12 @@ void xenstore_parse_domain_config(int hvm_domid)
     }
 
     /* Set a watch for vcpu-set */
-    if (pasprintf(&buf, "/local/domain/%u/cpu", domid) != -1) {
-        xs_watch(xsh, buf, "vcpu-set");
-        fprintf(logfile, "Watching %s\n", buf);
+    for (i = 0; i < vcpus; i++) {
+        if (pasprintf(&buf, "/local/domain/%u/cpu/%u/availability",
+                    domid, i) != -1) {
+            xs_watch(xsh, buf, "vcpu-set");
+            fprintf(logfile, "Watching %s\n", buf);
+        }
     }
 
     /* no need for ifdef CONFIG_STUBDOM, since in the qemu case
@@ -970,15 +973,14 @@ void xenstore_record_dm_state(const char *state)
 static void xenstore_process_vcpu_set_event(char **vec)
 {
     char *act = NULL;
-    char *vcpustr, *node = vec[XS_WATCH_PATH];
-    unsigned int vcpu, len;
+    char *node = vec[XS_WATCH_PATH];
+    unsigned int vcpu, len, domid;
 
-    vcpustr = strstr(node, "cpu/");
-    if (!vcpustr) {
-        fprintf(stderr, "vcpu-set: watch node error.\n");
+    if (sscanf(node, "/local/domain/%u/cpu/%u/availability",
+                &domid, &vcpu) <= 0) {
+        fprintf(stderr, "vcpu-set: watch node error, path=%s\n", node);
         return;
     }
-    sscanf(vcpustr, "cpu/%u", &vcpu);
 
     act = xs_read(xsh, XBT_NULL, node, &len);
     if (!act) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 17 lines · Jinsong
Quoted 10 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: fix cpu

hotplug"):

Quoted 4 lines

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it. This patch fixes both of them:

Thanks. So it seems you're saying it's completely broken in xen-unstable.

Stabellini, I read your attached patch, it's OK.
In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

Quoted 7 lines

However, we finally didn't use this scheme. We watch 'common' node instead:
/local/domain/xx/cpu
in this way, only 1 watch point need.
Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Does this scheme allow to say how many cores per cpu exist ?

When you run a Windows guest with a license for one cpu socket, then you can use 4 cores. But if one cpu is equal to one socket, then you can't use SMP for the Windows guest.

Christoph

Quoted 31 lines
Quoted 5 lines

I have CC'd a bunch of Intel folks who were doing some other work on cpu hotplug. They were dealing with a race when multiple CPUs were added at once.

Quoted 10 lines

So I think there must be some confusion. Perhaps xl and xend have different ideas about what the xenstore syntax is for these operations ?

Jinsong Liu et al: would you care to comment ? Particularly about

this:

Quoted 3 lines

A xenstore vcpu hotplug command is of the following form:
path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

Yes, I think there must be some confusion.
Currently 'xm vcpu-set' command works fine with both PV and HVM vcpu hotplug.

Stabellini/Jackson, would your please tell me what xl recently happened for vcpu hotplug? is there any different ideas xl and xend about xenstore syntax?
(Each time 'xm vcpu-set' executed, xend will write all xenstore cpu node status)

Quoted 5 lines

That doesn't seem to match up with what's in xend, which seems to write "cpu_avail" in the vm tree.

Thanks,
Ian.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#4 lore raw
Quoted 25 lines · Christoph Egger
Quoted 17 lines · Jinsong
Quoted 10 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: fix cpu

hotplug"):

Quoted 4 lines

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it. This patch fixes both of them:

Thanks. So it seems you're saying it's completely broken in xen-unstable.

Stabellini, I read your attached patch, it's OK.
In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

Quoted 6 lines

However, we finally didn't use this scheme. We watch 'common' node
instead: /local/domain/xx/cpu in this way, only 1 watch point need. Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Quoted 8 lines

Does this scheme allow to say how many cores per cpu exist ?

When you run a Windows guest with a license for one cpu socket, then you can use 4 cores. But if one cpu is equal to one socket, then you can't use SMP for the Windows guest.

Christoph

Seems this is another story?

Jinsong

Quoted 31 lines
Quoted 31 lines
Quoted 6 lines

I have CC'd a bunch of Intel folks who were doing some other work on cpu hotplug. They were dealing with a race when multiple CPUs were added at once.

Quoted 10 lines

So I think there must be some confusion. Perhaps xl and xend have different ideas about what the xenstore syntax is for these operations ?

Jinsong Liu et al: would you care to comment ? Particularly about

this:

Quoted 3 lines

A xenstore vcpu hotplug command is of the following form:
path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

Yes, I think there must be some confusion.
Currently 'xm vcpu-set' command works fine with both PV and HVM vcpu hotplug.

Stabellini/Jackson, would your please tell me what xl recently happened for vcpu hotplug? is there any different ideas xl and xend about xenstore syntax? (Each time 'xm vcpu-set' executed, xend will write all xenstore cpu node status)

Quoted 5 lines

That doesn't seem to match up with what's in xend, which seems to write "cpu_avail" in the vm tree.

Thanks,
Ian.

#5 lore raw
Quoted 28 lines · Jinsong
Quoted 27 lines · Christoph Egger
Quoted 17 lines · Jinsong
Quoted 10 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: fix cpu

hotplug"):

Quoted 4 lines

qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is also wrong the code to parse it. This patch fixes both of them:

Thanks. So it seems you're saying it's completely broken in xen-unstable.

Stabellini, I read your attached patch, it's OK.
In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

Quoted 6 lines

However, we finally didn't use this scheme. We watch 'common' node
instead: /local/domain/xx/cpu in this way, only 1 watch point need. Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Does this scheme allow to say how many cores per cpu exist ?

Quoted 9 lines
Quoted 6 lines

When you run a Windows guest with a license for one cpu socket, then you can use 4 cores. But if one cpu is equal to one socket, then you can't use SMP for the Windows guest.

Christoph

Seems this is another story?

Yes, the scheme we are talking about regards the communication of vcpu online and offline to qemu and nothing else.

#6 lore raw
In reply to Liu, Jinsong

Liu, Jinsong writes ("RE: [Xen-devel] [PATCH] qemu-xen: fix cpu hotplug"):

Quoted 1 line

Stabellini, I read your attached patch, it's OK.

So we should apply Stefano's patch ? I'm not sure I'm convinced.

Quoted 11 lines

In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

However, we finally didn't use this scheme. We watch 'common' node
instead: /local/domain/xx/cpu in this way, only 1 watch point need. Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Here you seem to be saying that the scheme that you implemented (in xend, I take it) is not the same as the one in Stefano's patch.

Quoted 2 lines

Yes, I think there must be some confusion.
Currently 'xm vcpu-set' command works fine with both PV and HVM vcpu hotplug.

Right, good.

Quoted 2 lines

Stabellini/Jackson, would your please tell me what xl recently happened for vcpu hotplug?

Well, we accepted patches to try to implement "xl vcpu-set" to make it work like "xm vcpu-set" but they are apparently wrong.

Quoted 1 line

is there any different ideas xl and xend about xenstore syntax?

xl should use the same syntax in xenstore as xend currently does. If xm (and therefore xend) and qemu currently work properly then changing qemu will break xend. Instead, libxl should be changed to use the same scheme as xend.

Quoted 2 lines

(Each time 'xm vcpu-set' executed, xend will write all xenstore cpu node status)

Right.

Thanks,
Ian.

#7 lore raw

Ian,

I have discussed with Stefano about current xl/xend situation:
1). current issue seems casued by xl side;
2). we don't need apply Stefano's patch, at least now;

Stefano, you will check xl side, right?

Thanks,
Jinsong

Quoted 47 lines · Ian Jackson

Liu, Jinsong writes ("RE: [Xen-devel] [PATCH] qemu-xen: fix cpu hotplug"):

Quoted 1 line

Stabellini, I read your attached patch, it's OK.

So we should apply Stefano's patch ? I'm not sure I'm convinced.

Quoted 11 lines

In fact, we firstly implemented xenstore watch by same scheme of your patch, watching each cpu node status:
/local/domain/xx/cpu/yy/availability=offline (online)

However, we finally didn't use this scheme. We watch 'common' node
instead: /local/domain/xx/cpu in this way, only 1 watch point need. Considering vcpu number may become more and more in the future (say, more than 128), it's more simple and reasonable. (Watches can be set at points in the hierarchy and an individual watch will be triggered when anything at or below that point in the hierachy changes)

Here you seem to be saying that the scheme that you implemented (in xend, I take it) is not the same as the one in Stefano's patch.

Quoted 3 lines

Yes, I think there must be some confusion.
Currently 'xm vcpu-set' command works fine with both PV and HVM vcpu hotplug.

Right, good.

Quoted 2 lines

Stabellini/Jackson, would your please tell me what xl recently happened for vcpu hotplug?

Well, we accepted patches to try to implement "xl vcpu-set" to make it work like "xm vcpu-set" but they are apparently wrong.

Quoted 1 line

is there any different ideas xl and xend about xenstore syntax?

xl should use the same syntax in xenstore as xend currently does. If xm (and therefore xend) and qemu currently work properly then changing qemu will break xend. Instead, libxl should be changed to use the same scheme as xend.

Quoted 2 lines

(Each time 'xm vcpu-set' executed, xend will write all xenstore cpu node status)

Right.

Thanks,
Ian.

#8 lore raw
Quoted 8 lines · Jinsong

Ian,

I have discussed with Stefano about current xl/xend situation:
1). current issue seems casued by xl side;
2). we don't need apply Stefano's patch, at least now;

Stefano, you will check xl side, right?

Yes. However I tried to reproduce the issue again but it seems to be gone now, maybe it was an error with my setup.