Re: [PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-26 Thread Rafael J. Wysocki
On Thursday, October 4, 2018 2:04:02 PM CEST Daniel Lezcano wrote:
> The function nr_iowait_cpu() can be used directly by nr_iowait() instead
> of duplicating code.
> 
> Call nr_iowait_cpu() from nr_iowait()
> 
> Reviewed-by: Rafael J. Wysocki 
> Signed-off-by: Daniel Lezcano 
> ---
>  kernel/sched/core.c | 41 -
>  1 file changed, 20 insertions(+), 21 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 625bc98..43efb74 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void)
>  }
>  
>  /*
> + * Consumers of these two interfaces, like for example the cpufreq menu
> + * governor are using nonsensical data. Boosting frequency 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(_rq(cpu)->nr_iowait);
> +}
> +
> +void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> +{
> + struct rq *rq = this_rq();
> + *nr_waiters = atomic_read(>nr_iowait);
> + *load = rq->load.weight;
> +}
> +
> +/*
>   * IO-wait accounting, and how its mostly bollocks (on SMP).
>   *
>   * The idea behind IO-wait account is to account the idle time that we could
> @@ -2909,31 +2928,11 @@ unsigned long nr_iowait(void)
>   unsigned long i, sum = 0;
>  
>   for_each_possible_cpu(i)
> - sum += atomic_read(_rq(i)->nr_iowait);
> + sum += nr_iowait_cpu(i);
>  
>   return sum;
>  }
>  
> -/*
> - * Consumers of these two interfaces, like for example the cpufreq menu
> - * governor are using nonsensical data. Boosting frequency 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(>nr_iowait);
> -}
> -
> -void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> -{
> - struct rq *rq = this_rq();
> - *nr_waiters = atomic_read(>nr_iowait);
> - *load = rq->load.weight;
> -}
> -
>  #ifdef CONFIG_SMP
>  
>  /*
> 

Both [1-2/2] applied with Peter's ACKs, thanks!



Re: [PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-26 Thread Rafael J. Wysocki
On Thursday, October 4, 2018 2:04:02 PM CEST Daniel Lezcano wrote:
> The function nr_iowait_cpu() can be used directly by nr_iowait() instead
> of duplicating code.
> 
> Call nr_iowait_cpu() from nr_iowait()
> 
> Reviewed-by: Rafael J. Wysocki 
> Signed-off-by: Daniel Lezcano 
> ---
>  kernel/sched/core.c | 41 -
>  1 file changed, 20 insertions(+), 21 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 625bc98..43efb74 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void)
>  }
>  
>  /*
> + * Consumers of these two interfaces, like for example the cpufreq menu
> + * governor are using nonsensical data. Boosting frequency 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(_rq(cpu)->nr_iowait);
> +}
> +
> +void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> +{
> + struct rq *rq = this_rq();
> + *nr_waiters = atomic_read(>nr_iowait);
> + *load = rq->load.weight;
> +}
> +
> +/*
>   * IO-wait accounting, and how its mostly bollocks (on SMP).
>   *
>   * The idea behind IO-wait account is to account the idle time that we could
> @@ -2909,31 +2928,11 @@ unsigned long nr_iowait(void)
>   unsigned long i, sum = 0;
>  
>   for_each_possible_cpu(i)
> - sum += atomic_read(_rq(i)->nr_iowait);
> + sum += nr_iowait_cpu(i);
>  
>   return sum;
>  }
>  
> -/*
> - * Consumers of these two interfaces, like for example the cpufreq menu
> - * governor are using nonsensical data. Boosting frequency 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(>nr_iowait);
> -}
> -
> -void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
> -{
> - struct rq *rq = this_rq();
> - *nr_waiters = atomic_read(>nr_iowait);
> - *load = rq->load.weight;
> -}
> -
>  #ifdef CONFIG_SMP
>  
>  /*
> 

Both [1-2/2] applied with Peter's ACKs, thanks!



Re: [PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-12 Thread Peter Zijlstra
On Thu, Oct 04, 2018 at 02:04:02PM +0200, Daniel Lezcano wrote:
> The function nr_iowait_cpu() can be used directly by nr_iowait() instead
> of duplicating code.
> 
> Call nr_iowait_cpu() from nr_iowait()
> 
> Reviewed-by: Rafael J. Wysocki 
> Signed-off-by: Daniel Lezcano 

Acked-by: Peter Zijlstra (Intel) 


Re: [PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-12 Thread Peter Zijlstra
On Thu, Oct 04, 2018 at 02:04:02PM +0200, Daniel Lezcano wrote:
> The function nr_iowait_cpu() can be used directly by nr_iowait() instead
> of duplicating code.
> 
> Call nr_iowait_cpu() from nr_iowait()
> 
> Reviewed-by: Rafael J. Wysocki 
> Signed-off-by: Daniel Lezcano 

Acked-by: Peter Zijlstra (Intel) 


[PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-04 Thread Daniel Lezcano
The function nr_iowait_cpu() can be used directly by nr_iowait() instead
of duplicating code.

Call nr_iowait_cpu() from nr_iowait()

Reviewed-by: Rafael J. Wysocki 
Signed-off-by: Daniel Lezcano 
---
 kernel/sched/core.c | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 625bc98..43efb74 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void)
 }
 
 /*
+ * Consumers of these two interfaces, like for example the cpufreq menu
+ * governor are using nonsensical data. Boosting frequency 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(_rq(cpu)->nr_iowait);
+}
+
+void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
+{
+   struct rq *rq = this_rq();
+   *nr_waiters = atomic_read(>nr_iowait);
+   *load = rq->load.weight;
+}
+
+/*
  * IO-wait accounting, and how its mostly bollocks (on SMP).
  *
  * The idea behind IO-wait account is to account the idle time that we could
@@ -2909,31 +2928,11 @@ unsigned long nr_iowait(void)
unsigned long i, sum = 0;
 
for_each_possible_cpu(i)
-   sum += atomic_read(_rq(i)->nr_iowait);
+   sum += nr_iowait_cpu(i);
 
return sum;
 }
 
-/*
- * Consumers of these two interfaces, like for example the cpufreq menu
- * governor are using nonsensical data. Boosting frequency 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(>nr_iowait);
-}
-
-void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
-{
-   struct rq *rq = this_rq();
-   *nr_waiters = atomic_read(>nr_iowait);
-   *load = rq->load.weight;
-}
-
 #ifdef CONFIG_SMP
 
 /*
-- 
2.7.4



[PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu

2018-10-04 Thread Daniel Lezcano
The function nr_iowait_cpu() can be used directly by nr_iowait() instead
of duplicating code.

Call nr_iowait_cpu() from nr_iowait()

Reviewed-by: Rafael J. Wysocki 
Signed-off-by: Daniel Lezcano 
---
 kernel/sched/core.c | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 625bc98..43efb74 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void)
 }
 
 /*
+ * Consumers of these two interfaces, like for example the cpufreq menu
+ * governor are using nonsensical data. Boosting frequency 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(_rq(cpu)->nr_iowait);
+}
+
+void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
+{
+   struct rq *rq = this_rq();
+   *nr_waiters = atomic_read(>nr_iowait);
+   *load = rq->load.weight;
+}
+
+/*
  * IO-wait accounting, and how its mostly bollocks (on SMP).
  *
  * The idea behind IO-wait account is to account the idle time that we could
@@ -2909,31 +2928,11 @@ unsigned long nr_iowait(void)
unsigned long i, sum = 0;
 
for_each_possible_cpu(i)
-   sum += atomic_read(_rq(i)->nr_iowait);
+   sum += nr_iowait_cpu(i);
 
return sum;
 }
 
-/*
- * Consumers of these two interfaces, like for example the cpufreq menu
- * governor are using nonsensical data. Boosting frequency 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(>nr_iowait);
-}
-
-void get_iowait_load(unsigned long *nr_waiters, unsigned long *load)
-{
-   struct rq *rq = this_rq();
-   *nr_waiters = atomic_read(>nr_iowait);
-   *load = rq->load.weight;
-}
-
 #ifdef CONFIG_SMP
 
 /*
-- 
2.7.4