static unsigned long scale_rt_capacity(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- u64 total, used, age_stamp, avg;
- s64 delta;
+ s64 used;
/*
- * Since we're reading these variables without serialization make sure
- * we read them once before doing sanity checks on them.
+ * Instread of rt_avg in rq, use the sched_rt_avg for more precise caculation
*/
- age_stamp = READ_ONCE(rq->age_stamp);
- avg = READ_ONCE(rq->rt_avg);
- delta = __rq_clock_broken(rq) - age_stamp;
-
- if (unlikely(delta < 0))
- delta = 0;
-
- total = sched_avg_period() + delta;
+ used = rq->rt.avg.util_avg;
- used = div_u64(avg, total);
+ /*
+ * Need to consider bandwidth of deadline tasks
+ */
if (likely(used < SCHED_CAPACITY_SCALE))
return SCHED_CAPACITY_SCALE - used;