2010-12-01 14:37:08

by Harry Nak

[permalink] [raw]
Subject: timer.c - high load avarage with idle cpu

Hi all,

I am developing an application on a at91rm9200 platform. Recently I
found out that the load average on this system is very high while the
cpu remains almost idle.
My application uses a lot of timers but the expiration of such a timer
causes almost no processing to be performed.

I think I found the reason for this load average/cpu usage
inconsistency and I (think I ) found a solution:

update_process_times() in timer.c first calls the function
run_local_timers() before calling scheduler_tick().

run_local_timers() raises TIMER_SOFTIRQ, which causes threads
associated with any expired timers to be marked RUNNABLE.
scheduler_tick() -> update_cpu_load() -> calc_load_account_active() ->
calc_load_fold_active() adds such a thread to the number of active
threads, thus causing the load average to increase. However this
particular thread never had to wait to become running and it will not
consume much cpu time.

My solution is to postpone the call to run_local_timers() until
scheduler_tick() has been called.

Could anybody confirm my theory and is it possible that my solution
breaks anything?

- Harry


2010-12-01 15:54:45

by Damien Wyart

[permalink] [raw]
Subject: Re: timer.c - high load avarage with idle cpu

Hi,

> [...]
> My solution is to postpone the call to run_local_timers() until
> scheduler_tick() has been called.

> Could anybody confirm my theory and is it possible that my solution
> breaks anything?

Your problem might be related to this thread:
https://lkml.org/lkml/2010/9/29/51

--
Damien

2010-12-02 10:00:23

by Harry Nak

[permalink] [raw]
Subject: Re: timer.c - high load avarage with idle cpu

Damien Wyart <[email protected]> wrote:
>> [...]
>> My solution is to postpone the call to run_local_timers() until
>> scheduler_tick() has been called.
>
>> Could anybody confirm my theory and is it possible that my solution
>> breaks anything?
>
> Your problem might be related to this thread:
> https://lkml.org/lkml/2010/9/29/51

Thanks for the hint. However from what I have read in this thread,
this deals specifically with a tickless kernel, while my issue
manifests on a regular HZ kernel.

- Harry