[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 06/19] xen: credit2: read NOW() with the proper runq lock held
Yet another situation very similar to 779511f4bf5ae ("sched: avoid races on time values read from NOW()"). In fact, when more than one runqueue is involved, we need to make sure that the following does not happen: 1. take the lock of 1st runq 2. now = NOW() 3. take the lock of 2nd runq 4. use now as, if we have to wait at step 3, the value in now may be stale when we get to use it at step 4. While there, fix the style of a label. Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- Cc: George Dunlap <george.dunlap@xxxxxxxxxx> Cc: Anshul Makkar <anshul.makkar@xxxxxxxxxx> Cc: David Vrabel <david.vrabel@xxxxxxxxxx> --- xen/common/sched_credit2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 9e8e561..50f8dfd 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1361,7 +1361,7 @@ static void balance_load(const struct scheduler *ops, int cpu, s_time_t now) __update_runq_load(ops, st.lrqd, 0, now); -retry: + retry: if ( !spin_trylock(&prv->lock) ) return; @@ -1377,7 +1377,8 @@ retry: || !spin_trylock(&st.orqd->lock) ) continue; - __update_runq_load(ops, st.orqd, 0, now); + /* Use a value of NOW() sampled after taking orqd's lock. */ + __update_runq_load(ops, st.orqd, 0, NOW()); delta = st.lrqd->b_avgload - st.orqd->b_avgload; if ( delta < 0 ) @@ -1435,6 +1436,8 @@ retry: if ( unlikely(st.orqd->id < 0) ) goto out_up; + now = NOW(); + /* Look for "swap" which gives the best load average * FIXME: O(n^2)! */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |