2002-07-10 14:47:36

by David Chow

[permalink] [raw]
Subject: CPU load

Dear all,

Is there any calls in the kernel space I can determine the current
system load or CPU load?

regards,
David




2002-07-10 16:53:07

by William Lee Irwin III

[permalink] [raw]
Subject: Re: CPU load

On Wed, Jul 10, 2002 at 10:50:15PM +0800, David Chow wrote:
> Is there any calls in the kernel space I can determine the current
> system load or CPU load?

Examine the avenrun array declared in kernel/timer.c in a manner similar
to how loadavg_read_proc() in fs/proc/proc_misc.c does.


Cheers,
Bill

2002-07-10 17:46:55

by Robert Love

[permalink] [raw]
Subject: Re: CPU load

On Wed, 2002-07-10 at 09:54, William Lee Irwin III wrote:

> Examine the avenrun array declared in kernel/timer.c in a manner similar
> to how loadavg_read_proc() in fs/proc/proc_misc.c does.

David, I wanted to add that we formalized the locking rules on
avenrun[3] a couple kernel revisions ago.

In 2.4, I believe it is implicitly assumed you will do a cli() before
accessing the data (if you want all 3 values to be in sync you need the
read to be safe).

In 2.5, grab a read_lock on xtime_lock and go at it.

Robert Love

2002-07-26 17:35:52

by David Chow

[permalink] [raw]
Subject: Re: CPU load

Robert Love wrote:

>On Wed, 2002-07-10 at 09:54, William Lee Irwin III wrote:
>
>
>
>>Examine the avenrun array declared in kernel/timer.c in a manner similar
>>to how loadavg_read_proc() in fs/proc/proc_misc.c does.
>>
>>
>
>David, I wanted to add that we formalized the locking rules on
>avenrun[3] a couple kernel revisions ago.
>
>In 2.4, I believe it is implicitly assumed you will do a cli() before
>accessing the data (if you want all 3 values to be in sync you need the
>read to be safe).
>
>In 2.5, grab a read_lock on xtime_lock and go at it.
>
> Robert Love
>
>

Thanks for your information. I think having a generic interface to
deterining CPU load of the system can help developers to determine some
task schdeuling policy to make the system more efficient utilise the
systems processing power. For example, I would not want to do some
intensive processing job when CPU load is high, but I can leaving this
work util the CPU load is not high (for non-urgent tasks).

regards,
David

regards,
David