diff options
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r-- | kernel/sched/core.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b8f4618407b2..974c9b2c0754 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2161,35 +2161,10 @@ unsigned long this_cpu_load(void) return this->cpu_load[0]; } -unsigned long avg_nr_running(void) -{ - unsigned long i, sum = 0; - unsigned int seqcnt, ave_nr_running; - - for_each_online_cpu(i) { - struct rq *q = cpu_rq(i); - - /* - * Update average to avoid reading stalled value if there were - * no run-queue changes for a long time. On the other hand if - * the changes are happening right now, just read current value - * directly. - */ - seqcnt = read_seqcount_begin(&q->ave_seqcnt); - ave_nr_running = do_avg_nr_running(q); - if (read_seqcount_retry(&q->ave_seqcnt, seqcnt)) { - read_seqcount_begin(&q->ave_seqcnt); - ave_nr_running = q->ave_nr_running; - } - - sum += ave_nr_running; - } - - return sum; -} - -unsigned long get_avg_nr_running(unsigned int cpu) +u64 nr_running_integral(unsigned int cpu) { + unsigned int seqcnt; + u64 integral; struct rq *q; if (cpu >= nr_cpu_ids) @@ -2197,7 +2172,21 @@ unsigned long get_avg_nr_running(unsigned int cpu) q = cpu_rq(cpu); - return q->ave_nr_running; + /* + * Update average to avoid reading stalled value if there were + * no run-queue changes for a long time. On the other hand if + * the changes are happening right now, just read current value + * directly. + */ + + seqcnt = read_seqcount_begin(&q->ave_seqcnt); + integral = do_nr_running_integral(q); + if (read_seqcount_retry(&q->ave_seqcnt, seqcnt)) { + read_seqcount_begin(&q->ave_seqcnt); + integral = q->nr_running_integral; + } + + return integral; } /* |