xen: domain_update_node_affinity: Correct the ASSERT
PATCH 1/1 xen: domain_update_node_affinity: Correct the ASSERT
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with d->vcpus allocated but no VCPU initialized.
Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC)
[<00000004>] 00000004 (LR)
[<00226870>] sched_move_domain+0x3cc/0x42c
[<0020925c>] domain_kill+0xc8/0x178
[<00206a0c>] do_domctl+0xaac/0x15e4
[<002529c0>] do_trap_hypervisor+0xc5c/0xf94
[<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if d->vcpu is allocated and VCPU 0 is initialized.
---
This patch should be backported to Xen 4.4
--- xen/common/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/domain.c +1 -1
@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));/* And compute the intersection between hard, online and soft */ cpumask_and (dom_cpumask_soft, dom_cpumask_soft, dom_cpumask);
Signature · 1 line
1.7.10.4
xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:30, <[email protected]> wrote:
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));
Wouldn't it be better for the function to bail early in that case?
Jan
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:30, <[email protected]> wrote:
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));Wouldn't it be better for the function to bail early in that case?
I've no idea. I mostly followed the advice on this thread:
http://www.gossamer-threads.com/lists/xen/devel/340233
Regards,
Signature · 1 line
Julien Grall
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:44, <[email protected]> wrote:
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:30, <[email protected]> wrote:
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));Wouldn't it be better for the function to bail early in that case?
Quoted 3 lines
I've no idea. I mostly followed the advice on this thread:
Yeah, I recall that discussion. But looking at the function, nothing useful will be done when the domain has no vCPU yet. Dario?
Jan
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:44, <[email protected]> wrote:
Hi Jan,
Quoted 11 lines · Jan Beulich
xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 17:30, <[email protected]> wrote:
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));Wouldn't it be better for the function to bail early in that case?
Quoted 7 lines
Quoted 3 lines
I've no idea. I mostly followed the advice on this thread:
Yeah, I recall that discussion. But looking at the function, nothing useful will be done when the domain has no vCPU yet. Dario?
For sure nothing useful happens if the for_each_vcpu() loop never executes, because of lack of vcpus.
Functionally wise, bailing or going ahead, but avoiding the ASSERT to trigger (as this patch does) is exactly the same.
I'm not sure which approach I personally prefer... If calling the function without any allocated vcpus is a "legitimate" and frequent enough use case, I'd say let's bail explicitly. If it's a corner case, then I think this patch is ok.
It looks to me like we're in the latter situation (corner case), so I'm actually fine with this patch. That's why I'm acking it, but really, it's a matter of taste.. FWIW, I'd ack a version that bails too.
Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 36 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) [<00000004>] 00000004 (LR) [<00226870>] sched_move_domain+0x3cc/0x42c [<0020925c>] domain_kill+0xc8/0x178 [<00206a0c>] do_domctl+0xaac/0x15e4 [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 [<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if
d->vcpuis allocated and VCPU 0 is initialized.Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>Cc Dario Faggioli <[email protected]>Cc Juergen Gross <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>---
This patch should be backported to Xen 4.4--- xen/common/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/common/domain.c +0
-0
xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 5 lines
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));
You don't actually care for the vcpu pointers themselves. You only care whether the domain has vcpus.
d->max_vcpus == 0 is a more appropriate check.
~Andrew
Quoted 3 lines
xen/common/domain.c +0
-0/* And compute the intersection between hard, online and soft */ cpumask_and (dom_cpumask_soft, dom_cpumask_soft, dom_cpumask);
Quoted 46 lines · Andrew Cooper
Quoted 36 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) [<00000004>] 00000004 (LR) [<00226870>] sched_move_domain+0x3cc/0x42c [<0020925c>] domain_kill+0xc8/0x178 [<00206a0c>] do_domctl+0xaac/0x15e4 [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 [<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if
d->vcpuis allocated and VCPU 0 is initialized.Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>Cc Dario Faggioli <[email protected]>Cc Juergen Gross <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>---
This patch should be backported to Xen 4.4--- xen/common/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/common/domain.c +0
-0xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 5 lines
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));You don't actually care for the vcpu pointers themselves. You only care whether the domain has vcpus.
Quoted 1 line
d->max_vcpus== 0 is a more appropriate check.
Actually no... max_vcpus has been set before Xen is allocating alloc_vcpu (see DOMCTL_max_vpus in common common/domctl.c).
So if Xen fails to allocate VCPU0, the hypervisor will still crash when the domain is killed.
Regards,
Signature · 1 line
Julien Grall
Quoted 46 lines · Julien Grall
Quoted 45 lines · Andrew Cooper
Quoted 36 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) [<00000004>] 00000004 (LR) [<00226870>] sched_move_domain+0x3cc/0x42c [<0020925c>] domain_kill+0xc8/0x178 [<00206a0c>] do_domctl+0xaac/0x15e4 [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 [<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if
d->vcpuis allocated and VCPU 0 is initialized.Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>Cc Dario Faggioli <[email protected]>Cc Juergen Gross <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>---
This patch should be backported to Xen 4.4--- xen/common/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/common/domain.c +0
-0xen/common/domain.c void domain_update_node_affinity(struct domain *d) · line 452
Quoted 5 lines
xen/common/domain.c +1
-1@@ -449,7 +449,7 @@ void domain_update_node_affinity(struct domain *d) }/* Filter out non-online cpus */ cpumask_and (dom_cpumask, dom_cpumask, online); -ASSERT (!cpumask_empty (dom_cpumask)); +ASSERT ( !d->vcpu || !d->vcpu[0 ] || !cpumask_empty (dom_cpumask));You don't actually care for the vcpu pointers themselves. You only care whether the domain has vcpus.
Quoted 9 lines
Quoted 1 line
d->max_vcpus== 0 is a more appropriate check.Actually no...
max_vcpushas been set before Xen is allocatingalloc_vcpu(seeDOMCTL_max_vpusin commoncommon/domctl.c).So if Xen fails to allocate VCPU0, the hypervisor will still crash when the domain is killed.
Regards,
Ah yes - I had mis-remembered the problem at hand. Sorry for the noise.
~Andrew
Quoted 3 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.
The title of the commit is certainly useful. Perhaps the beginning of the hash would have been too.
Quoted 12 lines
Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) [<00000004>] 00000004 (LR) [<00226870>] sched_move_domain+0x3cc/0x42c [<0020925c>] domain_kill+0xc8/0x178 [<00206a0c>] do_domctl+0xaac/0x15e4 [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 [<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if
d->vcpuis allocated and VCPU 0 is initialized.
Quoted 10 lines
Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>Cc Dario Faggioli <[email protected]>Cc Juergen Gross <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>
In any case:
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hi Dario,
Quoted 6 lines · Dario Faggioli
Quoted 3 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.The title of the commit is certainly useful. Perhaps the beginning of the hash would have been too.
I didn't add the commit. Because it will be backported to Xen 4.4.
Would it be fine to point to a Xen 4.5 commit in Xen 4.4 branch?
Quoted 22 lines
Quoted 12 lines
Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452 Xen call trace:
[<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC) [<00000004>] 00000004 (LR) [<00226870>] sched_move_domain+0x3cc/0x42c [<0020925c>] domain_kill+0xc8/0x178 [<00206a0c>] do_domctl+0xaac/0x15e4 [<002529c0>] do_trap_hypervisor+0xc5c/0xf94 [<002559f0>] return_from_trap+0/0x4Fix the ASSERT to check if
d->vcpuis allocated and VCPU 0 is initialized.Quoted 10 lines
Signed-off-by Julien Grall <[email protected]>Cc George Dunlap <[email protected]>Cc Dario Faggioli <[email protected]>Cc Juergen Gross <[email protected]>Cc Ian Campbell <[email protected]>Cc Ian Jackson <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir Fraser <[email protected]>Cc Tim Deegan <[email protected]>
Quoted 3 lines
In any case:
Reviewed-by Dario Faggioli <[email protected]>
Thanks!
Regards,
Signature · 1 line
Julien Grall
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 28.07.14 at 19:31, <[email protected]> wrote:
Quoted 4 lines · Dario Faggioli
Quoted 3 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.
Quoted 6 lines
Quoted 2 lines
The title of the commit is certainly useful. Perhaps the beginning of the hash would have been too.
I didn't add the commit. Because it will be backported to Xen 4.4.
Would it be fine to point to a Xen 4.5 commit in Xen 4.4 branch?
Yes. Backports are (supposed to be) identifiable (via some kind of reference to the backported commit), which would implicitly mean any commit IDs referenced in the description refer to the master branch. Furthermore, if someone wanted to look up the referenced commit, having the (beginning of the) hash in hands makes this a much more immediate action than just the title; I believe such a lookup would even succeed on any of the stable branches, as - luckily - we decided to make them branches rather than standalone trees.
Jan
Hi Jan,
Quoted 13 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 28.07.14 at 19:31, <[email protected]> wrote:
Quoted 4 lines · Dario Faggioli
Quoted 3 lines · Julien Grall
The commit "move domain to cpupool0 before destroying it" make Xen crashes when a domain is destroyed with
d->vcpusallocated but no VCPU initialized.Quoted 6 lines
Quoted 2 lines
The title of the commit is certainly useful. Perhaps the beginning of the hash would have been too.
I didn't add the commit. Because it will be backported to Xen 4.4.
Would it be fine to point to a Xen 4.5 commit in Xen 4.4 branch?
Quoted 9 lines
Yes. Backports are (supposed to be) identifiable (via some kind of reference to the backported commit), which would implicitly mean any commit IDs referenced in the description refer to the master branch. Furthermore, if someone wanted to look up the referenced commit, having the (beginning of the) hash in hands makes this a much more immediate action than just the title; I believe such a lookup would even succeed on any of the stable branches, as - luckily - we decided to make them branches rather than standalone trees.
Thank you for the explanation. I will send a v2 today with the commit ID of xen unstable in the message.
Regards,
Signature · 1 line
Julien Grall