mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xen: Introduce vcpu_sleep_nosync_locked()
There are a lot of places which release a lock before calling vcpu_sleep_nosync(), which then just grabs the lock again. This is not only a waste of time, but leads to more code duplication (since you have to copy-and-paste recipes rather than calling a unified function), which in turn leads to an increased chance of bugs. Introduce vcpu_sleep_nosync_locked(), which can be called if you already hold the schedule lock. Signed-off-by: George Dunlap <george.dunlap@citrix.com> Reviewed-by: Dario Faggioli <dfaggioli@suse.com> Release-acked-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
1 parent
47876e320b
commit
da0a5e00de
1 file changed
+14
-7
+14
-7
@@ -455,6 +455,19 @@ void sched_destroy_domain(struct domain *d)
|
||||
}
|
||||
}
|
||||
|
||||
void vcpu_sleep_nosync_locked(struct vcpu *v)
|
||||
{
|
||||
ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_lock));
|
||||
|
||||
if ( likely(!vcpu_runnable(v)) )
|
||||
{
|
||||
if ( v->runstate.state == RUNSTATE_runnable )
|
||||
vcpu_runstate_change(v, RUNSTATE_offline, NOW());
|
||||
|
||||
SCHED_OP(vcpu_scheduler(v), sleep, v);
|
||||
}
|
||||
}
|
||||
|
||||
void vcpu_sleep_nosync(struct vcpu *v)
|
||||
{
|
||||
unsigned long flags;
|
||||
@@ -464,13 +477,7 @@ void vcpu_sleep_nosync(struct vcpu *v)
|
||||
|
||||
lock = vcpu_schedule_lock_irqsave(v, &flags);
|
||||
|
||||
if ( likely(!vcpu_runnable(v)) )
|
||||
{
|
||||
if ( v->runstate.state == RUNSTATE_runnable )
|
||||
vcpu_runstate_change(v, RUNSTATE_offline, NOW());
|
||||
|
||||
SCHED_OP(vcpu_scheduler(v), sleep, v);
|
||||
}
|
||||
vcpu_sleep_nosync_locked(v);
|
||||
|
||||
vcpu_schedule_unlock_irqrestore(lock, flags, v);
|
||||
}
|
||||
|
||||