Skip to content

Commit

Permalink
sched: Factor out nr_iowait and nr_iowait_cpu
Browse files Browse the repository at this point in the history
The function nr_iowait_cpu() can be used directly by nr_iowait() instead
of duplicating code.

Call nr_iowait_cpu() from nr_iowait()

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Daniel Lezcano authored and Rafael J. Wysocki committed Oct 25, 2018
1 parent bd6bf7c commit 145d952
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void)
return sum;
}

/*
* Consumers of these two interfaces, like for example the cpuidle menu
* governor, are using nonsensical data. Preferring shallow idle state selection
* for a CPU that has IO-wait which might not even end up running the task when
* it does become runnable.
*/

unsigned long nr_iowait_cpu(int cpu)
{
return atomic_read(&cpu_rq(cpu)->nr_iowait);
}

void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
{
struct rq *rq = this_rq();
*nr_waiters = atomic_read(&rq->nr_iowait);
*load = rq->load.weight;
}

/*
* IO-wait accounting, and how its mostly bollocks (on SMP).
*
Expand Down Expand Up @@ -2910,31 +2929,11 @@ unsigned long nr_iowait(void)
unsigned long i, sum = 0;

for_each_possible_cpu(i)
sum += atomic_read(&cpu_rq(i)->nr_iowait);
sum += nr_iowait_cpu(i);

return sum;
}

/*
* Consumers of these two interfaces, like for example the cpuidle menu
* governor, are using nonsensical data. Preferring shallow idle state selection
* for a CPU that has IO-wait which might not even end up running the task when
* it does become runnable.
*/

unsigned long nr_iowait_cpu(int cpu)
{
struct rq *this = cpu_rq(cpu);
return atomic_read(&this->nr_iowait);
}

void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
{
struct rq *rq = this_rq();
*nr_waiters = atomic_read(&rq->nr_iowait);
*load = rq->load.weight;
}

#ifdef CONFIG_SMP

/*
Expand Down

0 comments on commit 145d952

Please sign in to comment.