A few OBSOLETE changes to linux 2.0.35 and procps 1.2.9
Last update: 27. November 2002 (see new note below)
Final Update - Please Read!
This is the final update to this page. I have just been informed by
Albert Cahalan, the current maintainer of the procps package, that the
changes proposed on this page have been incorporated into his
version. So, instead of patching old versions of procps, please go to the
official procps homepage at:
http://procps.sourceforge.net/.
Contents
On this page are a few changes to the linux 2.0.35 kernel and to the
procps utilities (version 1.2.9) to better support SMP and the ability
to view what's going on on the system. This is in no way perfect, but
it's probably a start...
Important note
As of procps-2.0.7 per-CPU system information is already included into
top, so there's no need for a patch anymore. Get the new procps
e.g. from http://freshmeat.net/ or
directly from ftp://people.redhat.com/johnsonm/procps/.
The following information is therefore out of date!
Old note
During the last few months I was too busy so I didn't have the time to
update this page. In the same time, my interests have shifted
somewhat, so I plan to no longer maintain this page.
If there is somebody who would like to maintain the patches and a
corresponding web-page, please contact me. There are still some
updates in my mail-INBOX which some people have sent to me. I'm sorry
that I didn't put them on the web. They are probably somewhat outdated
by now... If you want to create your own Linux-SMP-top-page, please
contact me and I will mail them to you. Otherwise, if there is
interest, I might just put them on the web-page with only little
comments.
However, Greg Warnes made a small page which contains his patches for
kernels 2.2.x. Please try http://queenbee.fhcrc.org/~warnes/procps/
(link seems broken now) until I update this page or until someone
offers his own page..
I am sorry for the inconvenience.
Procedure
Note for users of other linux kernel versions than 2.0.35: The
described procedure should also work on kernels similar to 2.0.35,
such as 2.0.31-2.0.34. For linux 2.1.x (where x is > 96, I just
checked it on 2.1.109) you don't need all the kernel-patches, see
below. If you just leave away all kernel patches, you will still see
activity-summaries for the individual processors, but you will not see
the processor a specific process is running on.
What you need to do is more or less the following:
(Note for linux 2.1.x (x > 96): Just skip over the points marked with
"(-)" )
- If you don't already have them, get the sources for procps
(e.g. from here: ftp://sunsite.cnlab-switch.ch/mirror/linux/distributions/redhat/redhat-5.0/updates/SRPMS/procps-1.2.7-1.src.rpm
or as a .tar.gz file from here: ftp://sunsite.cnlab-switch.ch/mirror/linux/sunsite/system/status/ps/procps-1.2.9.tar.gz
(the second is an older version, use the right patch below).
- Apply this small kernel patch to
/usr/src/linux/fs/proc/array.c (it's intended for 2.0.x kernels such
as 2.0.35)
(Note: If you have not yet applied patches 2-4 on your system, you may
also use the following single patch instead of the patches from steps 2-4:
smp-2.0.35.patch)
From above your Linux source directory (usually /usr/src/), do:
patch < /path_to_the_patch/array.c.2.0.35.patch
If you have a Linux 2.1.1xx kernel such as 2.1.109, you should
try this patch instead.
For the newest kernels such as 2.1.115, use
this patch (it has been
reported that it also works with 2.1.117, 2.1.119). For the even newer
kernels such as 2.1.123, try this
patch.
From above your Linux source directory do:
patch < /patch/to/array.c.2.1.xxx.patch
- (-)Apply this kernel patch (not written by me, but I do no longer
know by whom :-( ). It fixes the recording of process-times on SMP
machines: irq.h.patch
From above your Linux source directory (usually /usr/src/), do:
cd include/asm; patch < /path_to_the_patch/irq.h.patch
- (-)Don't forget to apply the smp cpu usage patch
smp_cpu_usage.diff by Jerome
Forissier.
From inside your Linux source directory (usually /usr/src/linux), do:
patch < /path_to_the_patch/smp_cpu_usage.diff
- Apply the following patch to your procps sourcedirectory:
procps-1.2.9.smp.patch2
From above your procps source directory (usually called procps-1.2.9
somewhere in your homedirectory), do:
patch < /path_to_the_patch/procps-1.2.9.smp.patch
Note: If you are using procps-1.2.7-5 (which is part of Redhat
Linux 5.1) or if you are using procps-1.2.8, then you have to do the
following: Download the patch procps-1.2.7.smp.patch5. From inside your procps source directory, do:
patch -p1 < /path_to_the_patch/procps-1.2.7.smp.patch5
You will then probably be asked the following question:
Patching file proc/whattime.c using Plan A...
Reversed (or previously applied) patch detected! Assume -R? [y]
Answer it with "n". You will then be asked:
Apply anyway? [n]
Here you just press return, answering the question with the default "n".
- Compile the procps utilities.
To do so, go to your procps sourcedirectory and type "make".
If you also want to install it on your system, type "make install"
(you have to be root for this).
- Compile your kernel (and do whatever you need).
- Reboot and use the new top, ps, etc. from your procps
sourcedirectory. Don't forget to use your new library libproc.so.1.2.6
(e.g. by setting your LD_LIBRARY_PATH environment variable).
Results
On my system, the output of top (in Irix-mode) looks now as follows:
1:02pm up 7 days, 2:14, 16 users, load average: 2.13, 2.18, 2.30
97 processes: 94 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: 198.2% user, 1.7% system, 197.6% nice, 0.2% idle
CPU0 states: 98.3% user, 1.3% system, 97.3% nice, 0.0% idle
CPU1 states: 100.0% user, 0.0% system, 100.0% nice, 0.0% idle
Mem: 63120K av, 61384K used, 1736K free, 20988K shrd, 14500K buff
Swap: 100796K av, 29384K used, 71412K free 18436K cached
PID USER PRI NI SIZE RSS SHARE LC STAT %CPU %MEM TIME COMMAND
21060 rauch 19 19 296 240 152 1 R N 99.6 0.3 3722m rc5des
17683 rauch 19 19 296 240 152 1 R N 98.0 0.3 4518m rc5des
31879 rauch 2 0 584 584 392 0 R 1.3 0.9 0:00 top
The output of the Sun-mode is slightly different (you can switch
bewteen the two modes by pressing "I" (capital i)):
1:06pm up 7 days, 2:18, 16 users, load average: 2.12, 2.10, 2.23
97 processes: 94 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: 96.9% user, 1.6% system, 95.6% nice, 1.5% idle
CPU0 states: 94.0% user, 5.0% system, 91.3% nice, 0.0% idle
CPU1 states: 99.2% user, 0.1% system, 99.2% nice, 0.0% idle
Mem: 63120K av, 61424K used, 1696K free, 21016K shrd, 14500K buff
Swap: 100796K av, 29364K used, 71432K free 18380K cached
PID USER PRI NI SIZE RSS SHARE LC STAT %CPU %MEM TIME COMMAND
21060 rauch 19 19 296 240 152 0 R N 48.7 0.3 3726m rc5des
17683 rauch 20 19 296 240 152 1 R N 46.9 0.3 4522m rc5des
31879 rauch 2 0 584 584 392 1 R 0.6 0.9 0:04 top
Where LC (Last Cpu) is the last CPU on which a task was running. You
can also switch on a column called CC (Current Cpu), which gives the
CPU a process is currently running on. This has some bugs
though, so it's not switched on by default. To switch on and off
columns, press "f" and select whatever you want in that menu.
Bug note: Sometimes, more then one process is shown to be on one
CPU. I guess this comes from the fact that a process may be moved to
another CPU while top is reading from the /proc filesystem. Any hints
to solve this problem are apreciated.
On another machine with 4 processors, it looks similar to this one
(it's taken from an earlier version):
8:51am up 19 min, 5 users, load average: 0.06, 0.10, 0.13
39 processes: 37 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 0.1% user, 0.6% system, 0.1% nice, 99.3% idle
CPU0 states: 0.0% user, 0.1% system, 0.0% nice, 99.9% idle
CPU1 states: 0.1% user, 0.7% system, 0.1% nice, 99.1% idle
CPU2 states: 0.0% user, 0.8% system, 0.0% nice, 99.2% idle
CPU4 states: 0.0% user, 2.3% system, 0.10% nice, 96.6% idle
Mem: 516424K av, 32124K used, 484300K free, 12820K shrd, 15748K buff
Swap: 128516K av, 0K used, 128516K free 4836K
cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU CPU %MEM TIME COMMAND
596 root 5 0 616 616 408 S 1.1 0 0.1 0:07 top
29 root 2 0 252 252 188 S 1.0 0 0.0 0:03 update
Final note: The changes work fine on my linux-machine with two 200 MHz
PentiumPros running linux 2.0.32, but there's absolutely no warranty
that this will work on any other system (it should, though...). Please
note that I'm speaking for myself only and not for my employer.
Credits
I would like to thank the following people:
[ CS-Department
| Institut for Computer Systems
| Research Group
| Homepage
| Up ]
Felix Rauch (rauch@inf.ethz.ch).
Homepage: http://www.cs.inf.ethz.ch/~rauch/.
Last changed: 27-Nov-2002