Incorrect computation for CPU system overhead (2.2.x and 2.3.x)

From: Bernard Beauchamp (bernard.beauchamp@free.fr)
Date: Fri Apr 21 2000 - 04:31:08 EST


CPU system overhead is always underestimated, especially on systems with low user activity and high network activity.
This is due to the fact that the system ticks, occurring while the "idle" processes (pid 0) are running, are not taken into account for system overhead computations.

In 2.3.99-pre5: linux/arch/I386/kernel/apic.c: (similar changes should also be applied to the other platforms in smp.c)
 routine smp_local_timer_interrupt should be modified:
 
  if (p->pid) {
   p->counter -= 1;
   if (p->counter <= 0) {
    p->counter = 0;
    p->need_resched = 1;
   }
   if (p->priority < DEF_PRIORITY) {
    kstat.cpu_nice += user;
    kstat.per_cpu_nice[cpu] += user;
   } else {
    kstat.cpu_user += user;
    kstat.per_cpu_user[cpu] += user;
   }
   kstat.cpu_system += system;
   kstat.per_cpu_system[cpu] += system;
  }

 to:

  if (p->pid) {
   p->counter -= 1;
   if (p->counter <= 0) {
    p->counter = 0;
    p->need_resched = 1;
   }
   if (p->priority < DEF_PRIORITY) {
    kstat.cpu_nice += user;
    kstat.per_cpu_nice[cpu] += user;
   } else {
    kstat.cpu_user += user;
    kstat.per_cpu_user[cpu] += user;
   }
 }
 kstat.cpu_system += system;
 kstat.per_cpu_system[cpu] += system;

 and in linux/kernel/timer.c:
routine update_process_times show be modified:

if (p->pid) {
  p->counter -= ticks;
  if (p->counter <= 0) {
   p->counter = 0;
   p->need_resched = 1;
  }
  if (p->priority < DEF_PRIORITY)
   kstat.cpu_nice += user;
  else
   kstat.cpu_user += user;
  kstat.cpu_system += system;
 }
 update_one_process(p, ticks, user, system, 0);

to

 if (p->pid) {
  p->counter -= ticks;
  if (p->counter <= 0) {
   p->counter = 0;
   p->need_resched = 1;
  }
  if (p->priority < DEF_PRIORITY)
   kstat.cpu_nice += user;
  else
   kstat.cpu_user += user;
  }
  kstat.cpu_system += system;
  update_one_process(p, ticks, user, system, 0);

  
In 2.2.14 linux/arch/I386/kernel/smp.c: (similar changes should also be applied to the other platforms)
 routine smp_local_timer_interrupt should be modified:

  if (p->pid) {
       p->counter -= 1;
       if (p->counter < 0) {
            p->counter = 0;
            p->need_resched = 1;
       }
   if (p->priority < DEF_PRIORITY) {
    kstat.cpu_nice += user;
    kstat.per_cpu_nice[cpu] += user;
   } else {
    kstat.cpu_user += user;
    kstat.per_cpu_user[cpu] += user;
   }
   kstat.cpu_system += system;
   kstat.per_cpu_system[cpu] += system;
  }

to:

if (p->pid) {
   p->counter -= 1;
   if (p->counter < 0) {
    p->counter = 0;
    p->need_resched = 1;
   }
   if (p->priority < DEF_PRIORITY) {
    kstat.cpu_nice += user;
    kstat.per_cpu_nice[cpu] += user;
   } else {
    kstat.cpu_user += user;
    kstat.per_cpu_user[cpu] += user;
   }
}
kstat.cpu_system += system;
kstat.per_cpu_system[cpu] += system;

 and in linux/kernel/sched.c:
routine update_process_times show be modified:

 if (p->pid) {
  p->counter -= ticks;
  if (p->counter < 0) {
   p->counter = 0;
   p->need_resched = 1;
  }
  if (p->priority < DEF_PRIORITY)
   kstat.cpu_nice += user;
  else
   kstat.cpu_user += user;
  kstat.cpu_system += system;
 }

to:
if (p->pid) {
  p->counter -= ticks;
  if (p->counter < 0) {
   p->counter = 0;
   p->need_resched = 1;
  }
  if (p->priority < DEF_PRIORITY)
   kstat.cpu_nice += user;
  else
   kstat.cpu_user += user;
  }
  kstat.cpu_system += system;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:18 EST