fix multicall state tracking
PATCH 1/1 fix multicall state tracking
This replaces the previous fix to multicall state tracking so that now the multicall- in-progress status is maintained on a per-VCPU basis (all other state remains per physical CPU). This seems cleaner than the previous hack requiring clearing of the flags in domain_crash_synchronous().
xen/arch/ia64/xen/hypercall.c +1 -1
@@ -320,7 +320,7 @@ unsigned long hypercall_create_continuatva_list args;va_start (args, format); -if (test_bit (_MCSF_in_multicall, &mcs->flags) ) { +if (test_bit (_VCPUF_in_multicall, &v->vcpu_flags) ) {panic ("PREEMPT happen in multicall\n" );// Not support yet }else {vcpu_set_gr (v,2 , op,0 );
xen/arch/x86/domain.c +1 -1
@@ -811,7 +811,7 @@ unsigned long hypercall_create_continuatva_start (args, format); -if (test_bit (_MCSF_in_multicall, &mcs->flags) ) +if (test_bit (_VCPUF_in_multicall, ¤t->vcpu_flags) ) {__set_bit (_MCSF_call_preempted, &mcs->flags);
xen/common/domain.c +0 -14
@@ -22,7 +22,6 @@#include <xen/delay.h> #include <xen/shutdown.h> #include <xen/percpu.h> -#include <xen/multicall.h> #include <asm/debugger.h> #include <public/sched.h> #include <public/vcpu.h>
@@ -258,19 +257,6 @@ void __domain_crash_synchronous(void) {__domain_crash (current->domain); -/* -* Flush multicall state before dying if a multicall is in progress. -* This shouldn't be necessary, but some architectures are calling -* domain_crash_synchronous() when they really shouldn't (i.e., from -* within hypercall context). -*/ -if (this_cpu (mc_state).flags !=0 ) - { -dprintk (XENLOG_ERR , -"FIXME: synchronous domain crash during a multicall!\n" ); -this_cpu (mc_state).flags =0 ; - } -for ( ; ; )do_softirq (); }
xen/common/multicall.c +5 -1
@@ -19,10 +19,11 @@ long do_multicall( XEN_GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls) { +struct vcpu *v = current;struct mc_state *mcs = &this_cpu (mc_state);unsigned int i; -if (unlikely (__test_and_set_bit (_MCSF_in_multicall, &mcs->flags)) ) +if (unlikely (test_and_set_bit (_VCPUF_in_multicall, &v->vcpu_flags)) ) {gdprintk (XENLOG_INFO ,"Multicall reentry is disallowed.\n" );return -EINVAL ;
@@ -66,14 +67,17 @@ do_multicall(guest_handle_add_offset (call_list,1 ); } +clear_bit (_VCPUF_in_multicall, &v->vcpu_flags); mcs->flags =0 ;return 0 ; fault: +clear_bit (_VCPUF_in_multicall, &v->vcpu_flags); mcs->flags =0 ;return -EFAULT ; preempted: +clear_bit (_VCPUF_in_multicall, &v->vcpu_flags); mcs->flags =0 ;return hypercall_create_continuation ( __HYPERVISOR_multicall,"hi" , call_list, nr_calls-i);
xen/include/xen/multicall.h +1 -3
@@ -8,9 +8,7 @@#include <xen/percpu.h> #include <asm/multicall.h> -#define _MCSF_in_multicall 0 -#define _MCSF_call_preempted 1 -#define MCSF_in_multicall (1<<_MCSF_in_multicall) +#define _MCSF_call_preempted 0#define MCSF_call_preempted (1<<_MCSF_call_preempted)struct mc_state {unsigned long flags;
xen/include/xen/sched.h +2 -0
@@ -399,6 +399,8 @@ extern struct domain *domain_list;/* VCPU affinity has changed: migrating to a new CPU. */ #define _VCPUF_migrating 13#define VCPUF_migrating (1UL<<_VCPUF_migrating) +#define _VCPUF_in_multicall 14 +#define VCPUF_in_multicall (1UL<<_VCPUF_in_multicall)/* * Per-domain flags (domain_flags).
Quoted 8 lines · Jan Beulich
This replaces the previous fix to multicall state tracking so that now the multicall-
in-progress status is maintained on a per-VCPU basis (all other state remains per physical CPU). This seems cleaner than the previous hack requiring clearing
of the flags indomain_crash_synchronous().Signed-off-by Jan Beulich <[email protected]>
I decided to entirely move away from domain_crash_synchronous() in hypercall context. So the code in domain_crash_synchronous() is just a warning for errant code -- later it can become BUG_ON(). This means that multicall state can remain per-cpu, unless per-vcpu seems much better (personally I think it doesn't really matter either way so we may as well stick with what we have).
-- Keir
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 14.12.06 11:36 >>>
Quoted 7 lines · Jan Beulich
This replaces the previous fix to multicall state tracking so that now the multicall-
in-progress status is maintained on a per-VCPU basis (all other state remains per physical CPU). This seems cleaner than the previous hack requiring clearing
of the flags indomain_crash_synchronous().
Quoted 7 lines
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>I decided to entirely move away from
domain_crash_synchronous()in hypercall context. So the code indomain_crash_synchronous()is just a warning for errant code -- later it can becomeBUG_ON(). This means that multicall state can remain per-cpu, unless per-vcpu seems much better (personally I think it doesn't really matter either way so we may as well stick with what we have).
But hypercall context to me seems exactly the right context for synchronously crashing a domain - am I missing something here? What else (if any) do you consider appropriate use of this (i.e. can't it go away then altogether)? I'm specifically asking because I have a patch (as talked about briefly before, pending for submission after 3.0.4) to replace the BUG() stuff with a more Linux-like approach, which at once also puts things like WARN() and also the crashing of a domain into the same framework. Obviously, if you consider domain_crash_synchronous() use ill in general, I shouldn't introduce a CRASH_ME() macro here.
Jan
Quoted 10 lines · Jan Beulich
But hypercall context to me seems exactly the right context for synchronously crashing a domain - am I missing something here? What else (if any) do you consider appropriate use of this (i.e. can't it go away then altogether)? I'm specifically asking because I have a patch (as talked about briefly before,
pending for submission after 3.0.4) to replace theBUG()stuff with a more Linux-like approach, which at once also puts things likeWARN()and also the crashing of a domain into the same framework. Obviously, if you considerdomain_crash_synchronous()use ill in general, I shouldn't introduce aCRASH_ME()macro here.
domain_crash() is fine, I just want to get rid of domain_crash_synchronous() in general, except in specialised cases like entry.S. It's used lazily and simply leads to broken error paths.
-- Keir