[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 08/16] xen: sched: prepare a .switch_sched hook for Credit2
RTDS is basically identical to Credit2, as far as scheduler lock (re)mapping is concerned. Therefore, the same analisys and considerations expressed for the previous patch ("xen: sched: prepare a .switch_sched hook for Credit2"), applies to it to. This patch, therefore, introduces the switch_sched hook for RTDS, as done already for Credit2 and Credit1. Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx> Cc: Meng Xu <mengxu@xxxxxxxxxxxxx> Cc: Tianyang Chen <tiche@xxxxxxxxxxxxxx> --- xen/common/sched_rt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index b6ac3ad..92be248 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -665,6 +665,36 @@ rt_init_pdata(const struct scheduler *ops, void *pdata, int cpu) spin_unlock_irqrestore(old_lock, flags); } +/* Change the scheduler of cpu to us (RTDS). */ +static void +rt_switch_sched(struct scheduler *new_ops, unsigned int cpu, + void *pdata, void *vdata) +{ + struct rt_vcpu *svc = vdata; + spinlock_t *old_lock; + + ASSERT(!pdata && svc && is_idle_vcpu(svc->vcpu)); + + /* + * We may be acquiring the lock of another scheduler here (the one cpu + * still belongs to when calling this function). That is ok as, anyone + * trying to schedule on this cpu will block until when we release that + * lock (bottom of this function). When unblocked --because of the loop + * implemented by schedule_lock() functions-- he will notice the lock + * changed, and acquire ours before being able to proceed. + */ + old_lock = pcpu_schedule_lock_irq(cpu); + + idle_vcpu[cpu]->sched_priv = vdata; + per_cpu(scheduler, cpu) = new_ops; + per_cpu(schedule_data, cpu).sched_priv = NULL; /* no pdata */ + /* (Re?)route the lock to our global lock. */ + per_cpu(schedule_data, cpu).schedule_lock = &rt_priv(new_ops)->lock; + + /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ + spin_unlock_irq(old_lock); +} + static void * rt_alloc_pdata(const struct scheduler *ops, int cpu) { @@ -1400,6 +1430,7 @@ static const struct scheduler sched_rtds_def = { .alloc_pdata = rt_alloc_pdata, .free_pdata = rt_free_pdata, .init_pdata = rt_init_pdata, + .switch_sched = rt_switch_sched, .alloc_domdata = rt_alloc_domdata, .free_domdata = rt_free_domdata, .init_domain = rt_dom_init, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |