sched: move vCPU exec state barriers
PATCH 1/1 sched: move vCPU exec state barriers
The barrier in vcpu_context_saved() is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.
Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
xen/arch/arm/domain.c +1 -11
@@ -333,17 +333,7 @@ void sync_local_execstate(void)void sync_vcpu_execstate (struct vcpu *v) { -/* -* We don't support lazy switching. -* -* However the context may have been saved from a remote pCPU so we -* need a barrier to ensure it is observed before continuing. -* -* Per vcpu_context_saved(), the context can be observed when -* v->is_running is false (the caller should check it before calling -* this function). -*/ -smp_rmb (); +/* Nothing to do -- no lazy switching */ }#define NEXT_ARG (fmt, args) \
xen/common/sched/core.c +8 -3
@@ -956,6 +956,9 @@ void vcpu_sleep_sync(struct vcpu *v)while ( !vcpu_runnable (v) && v->is_running )cpu_relax (); +/* Sync state /after/ observing the running flag clear. */ +smp_rmb (); +sync_vcpu_execstate (v); }
@@ -2308,11 +2311,13 @@ static struct sched_unit *do_schedule(ststatic void vcpu_context_saved (struct vcpu *vprev,struct vcpu *vnext) { -/* Clear running flag /after/ writing context to memory. */ -smp_wmb (); -if ( vprev != vnext ) + { +/* Clear running flag /after/ writing context to memory. */ +smp_wmb (); + vprev->is_running = false; + } }static void unit_context_saved (struct sched_resource *sr)
Quoted 8 lines · Jan Beulich
The barrier in
vcpu_context_saved()is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
Signed-off-by Jan Beulich <[email protected]>
Juergen
Quoted 6 lines · Jan Beulich
The barrier in
vcpu_context_saved()is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
Don't we want then move ...
Quoted 12 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/arm/domain.c +0
-3@@ -333,17 +333,7 @@ void sync_local_execstate(void)void sync_vcpu_execstate (struct vcpu *v) { -/* -* We don't support lazy switching. -*
xen/arch/arm/domain.c void sync_local_execstate(void) · line 337
Quoted 10 lines
xen/arch/arm/domain.c +1
-8-* However the context may have been saved from a remote pCPU so we -* need a barrier to ensure it is observed before continuing. -* -* Per vcpu_context_saved(), the context can be observed when -* v->is_running is false (the caller should check it before calling -* this function). -*/ -smp_rmb (); +/* Nothing to do -- no lazy switching */ }
... to common code with ability to re-define sync_vcpu_execstate() by arch as only x86 does something inside this function?
~ Oleksii
Quoted 28 lines · Oleksii Kurochko
Quoted 6 lines · Jan Beulich
The barrier in
vcpu_context_saved()is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
Don't we want then move ...
Quoted 17 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/arm/domain.c +0
-8@@ -333,17 +333,7 @@ void sync_local_execstate(void)void sync_vcpu_execstate (struct vcpu *v) { -/* -* We don't support lazy switching. -* -* However the context may have been saved from a remote pCPU so we -* need a barrier to ensure it is observed before continuing. -* -* Per vcpu_context_saved(), the context can be observed when -* v->is_running is false (the caller should check it before calling
Quoted 8 lines
xen/arch/arm/domain.c void sync_local_execstate(void) · line 337
Quoted 5 lines
xen/arch/arm/domain.c +1
-3-* this function). -*/ -smp_rmb (); +/* Nothing to do -- no lazy switching */ }... to common code with ability to re-define
sync_vcpu_execstate()by arch as only x86 does something inside this function?
Indeed this was considered already, as a possible next step.
Jan
Oleksii Kurochko
Reviewed-byQuoted 33 lines · Jan Beulich
Quoted 24 lines · Oleksii Kurochko
Quoted 6 lines · Jan Beulich
The barrier in
vcpu_context_saved()is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
Don't we want then move ...
Quoted 15 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/arm/domain.c +0
-7@@ -333,17 +333,7 @@ void sync_local_execstate(void)void sync_vcpu_execstate (struct vcpu *v) { -/* -* We don't support lazy switching. -* -* However the context may have been saved from a remote pCPU so we -* need a barrier to ensure it is observed before continuing. -* -* Per vcpu_context_saved(), the context can be observed when Quoted 8 lines
xen/arch/arm/domain.c void sync_local_execstate(void) · line 337
Quoted 6 lines
xen/arch/arm/domain.c +1
-4-* v->is_running is false (the caller should check it before calling -* this function). -*/ -smp_rmb (); +/* Nothing to do -- no lazy switching */ }... to common code with ability to re-define
sync_vcpu_execstate()by arch as only x86 does something inside this function?
Quoted 1 line
Indeed this was considered already, as a possible next step.
Oh, I missed that you wrote that in Arm-connected patch. Sorry for the noise then.
Then this patch looks good to me:
~ Oleksii
Hi Jan,
Quoted 8 lines · Jan Beulich
The barrier in
vcpu_context_saved()is specifically about the clearing of ->is_running. It isn't needed when we don't clear the flag.Furthermore, one side of the barrier being in common code, the other would better be, too. This way, all architectures are covered (beyond any specific needs they may have).
Signed-off-by Jan Beulich <[email protected]>
Cheers,
Signature · 1 line
Julien Grall