Is there any command to view what kernel is doing when I have a high kernel/system load??
On 11/25/05, Alberto xagonzalezm@gmail.com wrote:
Is there any command to view what kernel is doing when I have a high kernel/system load??
$top
$man top for details -- Sudev Barar Learning Linux
On Friday 25 November 2005 02:31, Alberto wrote:
Is there any command to view what kernel is doing when I have a high kernel/system load??
Unfortunately Linux has no real good way to determine that... Unless you got bad hardware (got any old qlogic fibre cards in your box by any change) there is most likely some process that is issueing a huge number of system calls. The other possibility is that some device causes a ton of interrupts.
The system call stuff is more likely. I would start with top and look for the process that has the highest cpu utilization - system calls usually also have some from of processing in user mode. Then use strace -p <pid> to check the process... Anything up to few pages per process per second is normal and generates nowhere the system load you're seeing. Most likely you'll end up with a process that spins in a loop and does stuff like stat, accept or read over and over again.
Peter.
On 11/26/05, Rob four4@naims.co.uk wrote:
On Fri, 2005-11-25 at 19:21 -0500, Peter Arremann wrote:
some from of processing in user mode. Then use strace -p <pid> to check the
Just tried this on a gnome-terminal process and locked up X. What did I do wrong?
That's probably a hardware problem.
Why not just use top?
Greg
On Saturday 26 November 2005 13:01, Greg Knaddison wrote:
On 11/26/05, Rob four4@naims.co.uk wrote:
On Fri, 2005-11-25 at 19:21 -0500, Peter Arremann wrote:
some from of processing in user mode. Then use strace -p <pid> to check the
Just tried this on a gnome-terminal process and locked up X. What did I do wrong?
That's probably a hardware problem.
I agree - if this happens, its likely hardware. What kind of hardware configuration do you have? Have you changed anything lately? Have you had this issue for a longer time or did it suddenly appear? What kind of applications do you run on that system?
Why not just use top?
Because top does not display the cause for the time spent in kernel mode.
Compile the following piece of code:
#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h>
int main () { struct stat buf; while (1) { stat ("/etc/passwd", &buf); //sync(); } }
You will see that your system spends near 100% of its time in kernel mode. Top will show the same. Start some other apps, do other things, the display will never change.
Then uncomment the line with the sync and put the comment in front of stat. Recompile, and re run. Again, you'll see a high percentage of kernel time, and the program will show that it is the cause. Now, again start using other software. The time spent writing their own data to disk is then added to the other process' timing and if you do enough IO, you will see the process that issues the sync only having a few percent cpu time. A simple "dd if=/dev/zero of=/dev/null" should be higher on your list than
There are many other system calls that for one reason or another are not reported correctly by top. Top is a very good starting point but in a busy system it is fairly unreliable. Strace also tells you what kind of work the process is doing and if you have some programming experience that often points you directly at the problem.
Peter.