lkml.org 
[lkml]   [1996]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: system time and idle time
Date
> I have found a small problem with .80.  procinfo shows zero idle time for
> the system and 90% system time. top on the other hand show some idle time.
> manual inspection of /proc/stat has a zero in the last field of cpu. I
> don't notice any system slow down (if the system really were working that
> hard). Maybe it is a just a /proc error. Any ideas....

I'm pretty sure it's not a proc error. That code is
straightforward. array.c just reports (get_kstat()):

kstat.cpu_user,
kstat.cpu_nice,
kstat.cpu_system,
jiffies - (kstat.cpu_user + kstat.cpu_nice + kstat.cpu_system),

The only place kstat.cpu_system is set (indeed, referenced)
is in sched.c, in do_process_times().

do_process_times() is called only by update_one_process().

update_one_process() is local to sched.c, and is called
only by update_process_times().

Assume we're not running SMP.

Incidentally, this is code that was changed in the patch of
79->80:
--- v1.3.79/linux/kernel/sched.c Mon Mar 25 08:58:23 1996
+++ linux/kernel/sched.c Thu Mar 28 08:25:09 1996
@@ -923,9 +923,8 @@
p->counter = 0;
need_resched = 1;
}
-
- update_one_process(p, ticks, ticks-system, system);
}
+ update_one_process(p, ticks, ticks-system, system);
#else
int cpu,j;
cpu = smp_processor_id();
It used to be this:

static void update_process_times(unsigned long ticks, unsigned long system)
{
struct task_struct * p = current;
if (p->pid) {
p->counter -= ticks;
if (p->counter < 0) {
p->counter = 0;
need_resched = 1;
}
update_one_process(p, ticks, ticks-system, system);
}
}
Now it is this:

static void update_process_times(unsigned long ticks, unsigned long system)
{
struct task_struct * p = current;
if (p->pid) {
p->counter -= ticks;
if (p->counter < 0) {
p->counter = 0;
need_resched = 1;
}
}
update_one_process(p, ticks, ticks-system, system);
}
In other words, it used not to run update_one_process on the
idle task, and now it does.

Incidentally, this is what's expected, from proc(5):
cpu 3357 0 4313 1362393
The number of jiffies (1/100ths of a second)
that the system spent in user mode, user
mode with low priority (nice), system mode,
and the idle task, respectively. The last
value should be 100 times the second entry
in the uptime pseudo-file.

hmm. my "cat /proc/uptime /proc/stat":
42114.64 41125.21
cpu 78451 0 4133013 0
[etc]

hmm.

The patch to sched.c is wrong. Or at least inadequate.

Assume that for some reason, we *do* want to run
update_one_process on the idle process. Then
do_process_times must be patched, at least.

here's the code (at the top of do_process_times) to patch:
p->utime += user;
if (p->priority < DEF_PRIORITY)
kstat.cpu_nice += user;
else
kstat.cpu_user += user;
kstat.cpu_system += system;
p->stime += system;
and here's a possible solution:

p->utime += user;
if (!p->pid) {
if (p->priority < DEF_PRIORITY)
kstat.cpu_nice += user;
else
kstat.cpu_user += user;
kstat.cpu_system += system;
}
p->stime += system;
this compiles cleanly, I think. I think I will go test it,
now.

BTW, I'm getting this single warning (which has nothing to
do with the subject at hand):

mouse.c: In function `mouse_init':
mouse.c:134: warning: implicit declaration of function `watchdog_init'

--
Michael J. Micek, peripatetic philosopher. (currently) mmicek@muddcs.cs.hmc.edu
Am hirable (consulting, problem-solving, whatever). Finger for details.


\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.061 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site