Re: [RFC PATCH 0/4] sched: Improve cpu load accounting with nohz
From: Byungchul Park
Date: Fri Jan 15 2016 - 02:08:09 EST
On Thu, Jan 14, 2016 at 10:23:46PM +0000, Dietmar Eggemann wrote:
> On 01/14/2016 09:27 PM, Peter Zijlstra wrote:
> >On Thu, Jan 14, 2016 at 09:19:00PM +0000, Dietmar Eggemann wrote:
> >>@@ -4346,7 +4346,10 @@ static void __update_cpu_load(struct rq *this_rq, unsigned long this_load,
> >>
> >> /* scale is effectively 1 << i now, and >> i divides by scale */
> >>
> >>- old_load = this_rq->cpu_load[i] - tickless_load;
> >>+ if (this_rq->cpu_load[i] > tickless_load)
> >>+ old_load = this_rq->cpu_load[i] - tickless_load;
> >>+ else
> >>+ old_load = 0;
> >
> >Yeah, yuck. That'd go bad quick.
> >
>
> ... because I set it to 0? But after the decay function we add
> tickless_load to old_load. Maybe in case tickless_load >
> this_rq->cpu_load[i] we decay this_rq->cpu_load[i] and do not add
> tickless_load afterwards.
>
I re-checked the equation I expanded and fortunately found it had no
problem. I think there are several ways to do it correctly. That is,
option 1. decay the absolute value with decay_load_missed() and adjust
the sign.
option 2. make decay_load_missed() can handle negative value.
option 3. refer to the patch below. I think this option is the best.
-----8<-----