Re: [PATCH] sched: Folding nohz load accounting more accurate

Charles Wang
2012-06-15T14:27:22Z

On Tuesday, June 12, 2012 05:56 PM, Peter Zijlstra wrote:

> Also added Doug to CC, hopefully we now have everybody who pokes at this
> stuff.
>
> On Tue, 2012-06-12 at 17:34 +0800, Charles Wang wrote:
>> consider following case:
>>
>> 5HZ+1
>> | cpu0_load cpu1 cpu2 cpu3 calc_load_tasks
>> | 1 1 1 1
>> | -->calc_load 1
>> | 1 1 1 1
>> | -->calc_load 2
>> | 0 0 1 0
>> | -->calc_load 2+1-3=1
>
> Not sure but last time I did the math 2+1-3 ended up being 0.
>
>> | 1 1 0 1
>> | -->calc_load 1-1=0
>> V
>> 5HZ+11 -->calc_global_load 0
>>
>> actually the load should be around 3, but shows nearly 0.
>>
>> 1 tick is much long for some workloads.
>
> Yes, one tick is long for some stuff, but seeing we sample once every 5
> seconds a little fuzz around sampling the nr_running+nr_uninterruptible
> thing shouldn't be too bad.
>
> But I think I see what you're getting at.. lemme get more tea and ponder
> this a bit.
> .
>

In our mind per-cpu sampling for cpu idle and non-idle is equal. But
actually may not. For non-idle cpu sampling, it's right the load when
sampling. But for idle, cause of nohz, the sampling will be delayed to
nohz exit(less than 1 tick after nohz exit). Nohz exit is always caused
by processes woken up--non-idle model. It's not fair here, idle
calculated to non-idle.

time-expect-sampling
| time-do-sampling
| |
V V
-|-------------------------|--
start_nohz stop_nohz

This may explain why using my patch the load shows higher, also may
explain some reports about high load for current.

I tried a experiments, results showed better. Now i need more experiments.

Peter, is this right as i thought?