Professional Documents
Culture Documents
系统优化
周炯
上海艾基信 息技术有限 公司
# mpstat -P ALL 1 1
Linux 2.4.21-15.EL (raclinux1) 08/04/2004
CPU %user %nice %system %idle intr/s
all 19.50 0.00 31.50 49.00 111.00
0 27.00 0.00 42.00 31.00 111.00
1 12.00 0.00 21.00 67.00 111.00
CPU Activity - sar
• What is my CPU doing?: sar
# sar -u 2 3
Linux 2.4.21-15.EL (raclinux1) 08/04/2004
02:02:34 AM CPU %user %nice %system %idle
02:02:36 AM all 1.14 0.00 1.71 97.14
02:02:38 AM all 2.62 0.00 3.66 93.72
02:02:40 AM all 0.54 0.00 3.78 95.68
Average: all 1.45 0.00 3.09 95.46
CPU Activity - iostat
• What is my CPU doing?: iostat
# iostat -c 2 3
Linux 2.4.21-15.EL (raclinux1) 08/04/2004
avg-cpu: %user %nice %sys %idle
5.73 0.00 17.16 77.11
avg-cpu: %user %nice %sys %idle
4.62 0.00 27.18 68.21
avg-cpu: %user %nice %sys %idle
9.55 0.00 35.96 54.49
Linux Virtual Memory
• Each process is assigned a
contiguous address space in virtual
memory that maps process memory
allocations to the real memory
– User address space is a contiguous set
of pages and is limited to 4GB per
process
– Physical Address Extension (PAE), allows
access to more than 4GB of physical
memory
• RHat: ‘enterprise’ kernel (implied SMP)
• SuSE: 64GB kernel (implied SMP)
Swap
Swapped-in pages
Physical
memory (RAM)
Swapped-out pages
Virtual
memory Swap space (disk)
Measuring Swap
• How much is available/used?
– swapon -s (cat /proc/swaps)
– vmstat
• so: Amount of memory KB/s SWAP OUT to
disk
• si: Amount of memory KB/s SWAP IN from
disk
• swapd: Amount of virtual memory KB
reserved
• Create/Add more?
– # mkswap /dev/sdc3
– fstab: /dev/sdc3 swap swap pri=42
Memory Usage
Buffer cache
Dynamically adjusted
Page cache
Process memory
Process memory
Kernel modules
Not paged
Kernel (not paged)
Measuring Memory Usage
• Measure memory utilization and
paging. Identify the significant
Page out
Page in
memory statistics.
– cat /proc/meminfo (units KB)
• MemTotal: Total physical memory
• MemFree: Total free memory
• LowFree: Free memory below 1GB physical
• Buffers: Linux Buffer Cache
• Cached: Linux Page Cache
• BigFree: Free bigpages memory
No Free Memory?
• free command reports a very low
number, should I be worried
– It’s OK if Linux buffer or page cache are
big
– Look in -/+ buffer/cache row of free for
projected free memory
– Very useful stat
Memory - sar
• -B paging statistics
• -R memory statistics
• -W swapping statistics