Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-03-22 Thread Alex Shi
On 02/20/2013 11:22 PM, Peter Zijlstra wrote:
> On Wed, 2013-02-20 at 22:33 +0800, Alex Shi wrote:
>>> You don't actually compute the rq utilization, you only compute the
>>> utilization as per the fair class, so if there's significant RT
>> activity
>>> it'll think the cpu is under-utilized, whihc I think will result in
>> the
>>> wrong thing.
>>
>> yes. A bit complicit to resolve this. Any suggestions on this, guys?
> 
> Shouldn't be too hard seeing as we already track cpu utilization for !
> fair usage; see rq::rt_avg and scale_rt_power.
> 

Hi Peter,

rt_avg will be accumulated the irq time and steal time in
update_rq_clock_task(), if CONFIG_IRQ_TIME_ACCOUNTING or
CONFIG_IRQ_TIME_ACCOUNTING defined. That cause irq/steal time was double
added into rq utilisation, since normal rq->util already include the irq
time. So we do wrongly judgement to think it is a overload cpu. but it
is not.

To resolve this issue, if is it possible to introduce another member in
rq to describe rt_avg non irq/steal beside the rt_avg? If so, what the
name do you like to use?

-- 
Thanks Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-24 Thread Alex Shi
On 02/20/2013 11:22 PM, Peter Zijlstra wrote:
> On Wed, 2013-02-20 at 22:33 +0800, Alex Shi wrote:
>>> You don't actually compute the rq utilization, you only compute the
>>> utilization as per the fair class, so if there's significant RT
>> activity
>>> it'll think the cpu is under-utilized, whihc I think will result in
>> the
>>> wrong thing.
>>
>> yes. A bit complicit to resolve this. Any suggestions on this, guys?
> 
> Shouldn't be too hard seeing as we already track cpu utilization for !
> fair usage; see rq::rt_avg and scale_rt_power.
> 

added them in periodic balancing, thanks!

-- 
Thanks Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Alex Shi
On 02/20/2013 11:20 PM, Peter Zijlstra wrote:
> On Wed, 2013-02-20 at 22:33 +0800, Alex Shi wrote:
>>> There's generally a better value than 100 when using computers..
>> seeing
>>> how 100 is 64+32+4.
>>
>> I didn't find a good example for this. and no idea of your suggestion,
>> would you like to explain a bit more?
> 
> Basically what you're doing ends up being fixed point math, using 100 as
> unit is inefficient, pick a power-of-2 and everything reduces to
> bit-shifts.
> 
> http://en.wikipedia.org/wiki/Fixed-point_arithmetic
> 
> So use 128 or 1024 or whatever and you don't need mult and div
> instructions to represent [0,1]
> 

got it. will reconsider this.

-- 
Thanks Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Peter Zijlstra
On Wed, 2013-02-20 at 22:33 +0800, Alex Shi wrote:
> > You don't actually compute the rq utilization, you only compute the
> > utilization as per the fair class, so if there's significant RT
> activity
> > it'll think the cpu is under-utilized, whihc I think will result in
> the
> > wrong thing.
> 
> yes. A bit complicit to resolve this. Any suggestions on this, guys?

Shouldn't be too hard seeing as we already track cpu utilization for !
fair usage; see rq::rt_avg and scale_rt_power.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Peter Zijlstra
On Wed, 2013-02-20 at 22:33 +0800, Alex Shi wrote:
> > There's generally a better value than 100 when using computers..
> seeing
> > how 100 is 64+32+4.
> 
> I didn't find a good example for this. and no idea of your suggestion,
> would you like to explain a bit more?

Basically what you're doing ends up being fixed point math, using 100 as
unit is inefficient, pick a power-of-2 and everything reduces to
bit-shifts.

http://en.wikipedia.org/wiki/Fixed-point_arithmetic

So use 128 or 1024 or whatever and you don't need mult and div
instructions to represent [0,1]

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Alex Shi
On 02/20/2013 09:34 PM, Peter Zijlstra wrote:
> On Wed, 2013-02-20 at 17:39 +0530, Preeti U Murthy wrote:
>> Hi,
>>
  /*
   * This is the main, per-CPU runqueue data structure.
   *
 @@ -481,6 +484,7 @@ struct rq {
  #endif
  
struct sched_avg avg;
 +  unsigned int util;
  };
  
  static inline int cpu_of(struct rq *rq)
>>>
>>> You don't actually compute the rq utilization, you only compute the
>>> utilization as per the fair class, so if there's significant RT activity
>>> it'll think the cpu is under-utilized, whihc I think will result in the
>>> wrong thing.
>>
>> Correct me if I am wrong,but isn't the current load balancer also
>> disregarding the real time tasks to calculate the domain/group/cpu level
>> load too?
> 
> Nope, the rt utilization affects the cpu_power, thereby correcting the
> weight stuff.

The balance policy use group capacity, that implicated using cpu power,
but seems capacity is a very rough data.
> 
> 


-- 
Thanks
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Alex Shi
On 02/20/2013 05:30 PM, Peter Zijlstra wrote:
> On Mon, 2013-02-18 at 13:07 +0800, Alex Shi wrote:
> 
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index fcdb21f..b9a34ab 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -1495,8 +1495,12 @@ static void update_cfs_rq_blocked_load(struct cfs_rq 
>> *cfs_rq, int force_update)
>>  
>>  static inline void update_rq_runnable_avg(struct rq *rq, int runnable)
>>  {
>> +u32 period;
>>  __update_entity_runnable_avg(rq->clock_task, &rq->avg, runnable);
>>  __update_tg_runnable_avg(&rq->avg, &rq->cfs);
>> +
>> +period = rq->avg.runnable_avg_period ? rq->avg.runnable_avg_period : 1;
>> +rq->util = rq->avg.runnable_avg_sum * 100 / period;
>>  }
>>  
>>  /* Add the load generated by se into cfs_rq's child load-average */
>> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
>> index 7a19792..ac1e107 100644
>> --- a/kernel/sched/sched.h
>> +++ b/kernel/sched/sched.h
>> @@ -350,6 +350,9 @@ extern struct root_domain def_root_domain;
>>  
>>  #endif /* CONFIG_SMP */
>>  
>> +/* the percentage full cpu utilization */
>> +#define FULL_UTIL   100
> 
> There's generally a better value than 100 when using computers.. seeing
> how 100 is 64+32+4.

I didn't find a good example for this. and no idea of your suggestion,
would you like to explain a bit more?

> 
>> +
>>  /*
>>   * This is the main, per-CPU runqueue data structure.
>>   *
>> @@ -481,6 +484,7 @@ struct rq {
>>  #endif
>>  
>>  struct sched_avg avg;
>> +unsigned int util;
>>  };
>>  
>>  static inline int cpu_of(struct rq *rq)
> 
> You don't actually compute the rq utilization, you only compute the
> utilization as per the fair class, so if there's significant RT activity
> it'll think the cpu is under-utilized, whihc I think will result in the
> wrong thing.

yes. A bit complicit to resolve this. Any suggestions on this, guys?
> 


-- 
Thanks
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Peter Zijlstra
On Wed, 2013-02-20 at 17:39 +0530, Preeti U Murthy wrote:
> Hi,
> 
> >>  /*
> >>   * This is the main, per-CPU runqueue data structure.
> >>   *
> >> @@ -481,6 +484,7 @@ struct rq {
> >>  #endif
> >>  
> >>struct sched_avg avg;
> >> +  unsigned int util;
> >>  };
> >>  
> >>  static inline int cpu_of(struct rq *rq)
> > 
> > You don't actually compute the rq utilization, you only compute the
> > utilization as per the fair class, so if there's significant RT activity
> > it'll think the cpu is under-utilized, whihc I think will result in the
> > wrong thing.
> 
> Correct me if I am wrong,but isn't the current load balancer also
> disregarding the real time tasks to calculate the domain/group/cpu level
> load too?

Nope, the rt utilization affects the cpu_power, thereby correcting the
weight stuff.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Alex Shi
On 02/20/2013 08:19 PM, Preeti U Murthy wrote:
> Hi everyone,
> 
> On 02/18/2013 10:37 AM, Alex Shi wrote:
>> The cpu's utilization is to measure how busy is the cpu.
>> util = cpu_rq(cpu)->avg.runnable_avg_sum
>> / cpu_rq(cpu)->avg.runnable_avg_period;
> 
> Why not cfs_rq->runnable_load_avg? I am concerned with what is the right
> metric to use here.

Here we care the utilization of the cpu not the load avg. load avg maybe
quit bigger on a heavy task(with a big load weight), but maybe it just
used 20% of cpu time, while a light task with 100% cpu usage maybe still
has smaller load avg.

For power consideration, above light task with 100% usage need to take a
cpu, while another heavy task can packing into one cpu with other tasks.


> Refer to this discussion:https://lkml.org/lkml/2012/10/29/448
> 
> Regards
> Preeti U Murthy
> 


-- 
Thanks
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Preeti U Murthy
Hi everyone,

On 02/18/2013 10:37 AM, Alex Shi wrote:
> The cpu's utilization is to measure how busy is the cpu.
> util = cpu_rq(cpu)->avg.runnable_avg_sum
> / cpu_rq(cpu)->avg.runnable_avg_period;

Why not cfs_rq->runnable_load_avg? I am concerned with what is the right
metric to use here.
Refer to this discussion:https://lkml.org/lkml/2012/10/29/448

Regards
Preeti U Murthy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Preeti U Murthy
Hi,

>>  /*
>>   * This is the main, per-CPU runqueue data structure.
>>   *
>> @@ -481,6 +484,7 @@ struct rq {
>>  #endif
>>  
>>  struct sched_avg avg;
>> +unsigned int util;
>>  };
>>  
>>  static inline int cpu_of(struct rq *rq)
> 
> You don't actually compute the rq utilization, you only compute the
> utilization as per the fair class, so if there's significant RT activity
> it'll think the cpu is under-utilized, whihc I think will result in the
> wrong thing.

Correct me if I am wrong,but isn't the current load balancer also
disregarding the real time tasks to calculate the domain/group/cpu level
load too?

What I mean is,if the answer to the above question is yes,then can we
safely assume that the furthur optimizations to the load balancer like
the power aware scheduler and the usage of per entity load tracking can
be done without considering the real time tasks?

Regards
Preeti U Murthy
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v5 06/15] sched: log the cpu utilization at rq

2013-02-20 Thread Peter Zijlstra
On Mon, 2013-02-18 at 13:07 +0800, Alex Shi wrote:

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fcdb21f..b9a34ab 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1495,8 +1495,12 @@ static void update_cfs_rq_blocked_load(struct cfs_rq 
> *cfs_rq, int force_update)
>  
>  static inline void update_rq_runnable_avg(struct rq *rq, int runnable)
>  {
> + u32 period;
>   __update_entity_runnable_avg(rq->clock_task, &rq->avg, runnable);
>   __update_tg_runnable_avg(&rq->avg, &rq->cfs);
> +
> + period = rq->avg.runnable_avg_period ? rq->avg.runnable_avg_period : 1;
> + rq->util = rq->avg.runnable_avg_sum * 100 / period;
>  }
>  
>  /* Add the load generated by se into cfs_rq's child load-average */
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 7a19792..ac1e107 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -350,6 +350,9 @@ extern struct root_domain def_root_domain;
>  
>  #endif /* CONFIG_SMP */
>  
> +/* the percentage full cpu utilization */
> +#define FULL_UTIL100

There's generally a better value than 100 when using computers.. seeing
how 100 is 64+32+4.

> +
>  /*
>   * This is the main, per-CPU runqueue data structure.
>   *
> @@ -481,6 +484,7 @@ struct rq {
>  #endif
>  
>   struct sched_avg avg;
> + unsigned int util;
>  };
>  
>  static inline int cpu_of(struct rq *rq)

You don't actually compute the rq utilization, you only compute the
utilization as per the fair class, so if there's significant RT activity
it'll think the cpu is under-utilized, whihc I think will result in the
wrong thing.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch v5 06/15] sched: log the cpu utilization at rq

2013-02-17 Thread Alex Shi
The cpu's utilization is to measure how busy is the cpu.
util = cpu_rq(cpu)->avg.runnable_avg_sum
/ cpu_rq(cpu)->avg.runnable_avg_period;

Since the util is no more than 1, we use its percentage value in later
caculations. And set the the FULL_UTIL as 100%.

In later power aware scheduling, we are sensitive for how busy of the
cpu, not how much weight of its load. As to power consuming, it is more
related with cpu busy time, not load weight.

BTW, rq->util can be used for any purposes if needed, not only power
scheduling.

Signed-off-by: Alex Shi 
---
 kernel/sched/debug.c | 1 +
 kernel/sched/fair.c  | 4 
 kernel/sched/sched.h | 4 
 3 files changed, 9 insertions(+)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 7ae4c4c..d220354 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -318,6 +318,7 @@ do {
\
 
P(ttwu_count);
P(ttwu_local);
+   P(util);
 
 #undef P
 #undef P64
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fcdb21f..b9a34ab 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1495,8 +1495,12 @@ static void update_cfs_rq_blocked_load(struct cfs_rq 
*cfs_rq, int force_update)
 
 static inline void update_rq_runnable_avg(struct rq *rq, int runnable)
 {
+   u32 period;
__update_entity_runnable_avg(rq->clock_task, &rq->avg, runnable);
__update_tg_runnable_avg(&rq->avg, &rq->cfs);
+
+   period = rq->avg.runnable_avg_period ? rq->avg.runnable_avg_period : 1;
+   rq->util = rq->avg.runnable_avg_sum * 100 / period;
 }
 
 /* Add the load generated by se into cfs_rq's child load-average */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 7a19792..ac1e107 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -350,6 +350,9 @@ extern struct root_domain def_root_domain;
 
 #endif /* CONFIG_SMP */
 
+/* the percentage full cpu utilization */
+#define FULL_UTIL  100
+
 /*
  * This is the main, per-CPU runqueue data structure.
  *
@@ -481,6 +484,7 @@ struct rq {
 #endif
 
struct sched_avg avg;
+   unsigned int util;
 };
 
 static inline int cpu_of(struct rq *rq)
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/