From: Juergen Gross Date: Sat, 17 Sep 2011 15:19:26 +0000 (+0100) Subject: Avoid race in schedule() when switching schedulers X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~9893 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4dd27c01c31c55319758b47dccdba46ddd5f499e;p=xen.git Avoid race in schedule() when switching schedulers Selecting the scheduler to call must be done under lock. Otherwise a race might occur when switching schedulers in a cpupool Signed-off-by: Juergen Gross Acked-by: George Dunlap --- diff --git a/xen/common/schedule.c b/xen/common/schedule.c index cce22a5795..0f6d41ee96 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1107,7 +1107,7 @@ static void schedule(void) { struct vcpu *prev = current, *next = NULL; s_time_t now = NOW(); - struct scheduler *sched = this_cpu(scheduler); + struct scheduler *sched; unsigned long *tasklet_work = &this_cpu(tasklet_work_to_do); bool_t tasklet_work_scheduled = 0; struct schedule_data *sd; @@ -1141,6 +1141,7 @@ static void schedule(void) stop_timer(&sd->s_timer); /* get policy-specific decision on scheduling... */ + sched = this_cpu(scheduler); next_slice = sched->do_schedule(sched, now, tasklet_work_scheduled); next = next_slice.task;