[linuxperf] Incorrect computation for CPU system overhead (2.2.x and 2.3.x) (fwd)

From: Rik van Riel (riel@conectiva.com.br)
Date: Thu Apr 20 2000 - 10:10:53 EST


I found this on the linuxperf list...
I guess he has a point since CPU usage on heavy networking
servers will be underestimated by people, who then make the
wrong upgrading decisions and end up wasting money...

Rik
---------- Forwarded message ----------
Date: Wed, 19 Apr 2000 12:11:23 +0200
From: Bernard Beauchamp <bernard.beauchamp@free.fr>
Reply-To: linuxperf@nl.linux.org
To: linuxperf@nl.linux.org
Subject: [linuxperf] Incorrect computation for CPU system overhead (2.2.x
    and 2.3.x)

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:17 EST