IBM REDP-4285-00 User Manual

Page of 170
4285ch01.fm
Draft Document for Review May 4, 2007 11:35 am
6
 
Linux Performance and Tuning Guidelines
Linux supports nice levels from 19 (lowest priority) to -20 (highest priority). The default value 
is 0. To change the nice level of a program to a negative number (which makes it higher 
priority), it is necessary to log on or su to root.
1.1.5  Context switching
During process execution, information of the running process is stored in registers on 
processor and its cache. The set of data that is loaded to the register for the executing 
process is called the 
context
. To switch processes, the context of the running process is 
stored and the context of the next running process is restored to the register. The process 
descriptor and the area called kernel mode stack are used to store the context. This switching 
process is called 
context switching
. Having too much context switching is undesirable 
because the processor has to flush its register and cache every time to make room for the 
new process. It may cause performance problems.
Figure 1-5 illustrates how the context switching works.
Figure 1-5   Context switching
1.1.6  Interrupt handling
Interrupt handling is one of the highest priority tasks. Interrupts are usually generated by I/O 
devices such as a network interface card, keyboard, disk controller, serial adapter, and so on. 
The interrupt handler notifies the Linux kernel of an event (such as keyboard input, ethernet 
frame arrival, and so on). It tells the kernel to interrupt process execution and perform 
interrupt handling as quickly as possible because some device requires quick 
responsiveness. This is critical for system stability. When an interrupt signal arrives to the 
kernel, the kernel must switch a currently execution process to new one to handle the 
interrupt. This means interrupts cause context switching, and therefore a significant amount 
of interrupts may cause performance degradation.
In Linux implementations, there are two types of interrupt. A 
hard interrupt
 is generated for 
devices which require responsiveness (disk I/O interrupt, network adapter interrupt, keyboard 
interrupt, mouse interrupt). A 
soft interrupt
 is used for tasks which processing can be 
deferred (TCP/IP operation, SCSI protocol operation etc.). You can see information related to 
hard interrupts at /proc/interrupts.
stack pointer
other registers
EIP register
etc.
CPU
Address space
of process B
Address space
of process A
stack
stack
task_struct
(Process A)
task_struct
(Process B)
Suspend
Resume
Context switch