内存子系统
虚拟内存
swap
内存页(page)
page in , page out <--- paging(内存分页)
# free -m
total used free shared buffers cached
Mem: 2017 1963 54 0 6 1573
-/+ buffers/cache: 383 1634
Swap: 4094 0 4094
# vmstat 2 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 116 54912 7288 1612464 0 0 409 15 1128 1339 13 8 78 1 0
0 0 116 54912 7288 1612468 0 0 0 0 2493 3202 15 9 76 0 0
-----------memory---------- ---swap--
swpd free buff cache si so
116 54912 7288 1612464 0 0
116 54912 7288 1612468 0 0
si 从swap分区读取到内存
so 把内存中的数据写到swap
bi 从块设备读取数据到内存
bo 把内存上数据写回硬盘
查看主页面故障,次页面故障
# /usr/bin/time -v date
...
/usr/bin/time -v date
Wed Jul 31 14:04:28 CST 2013
Command being timed: "date"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 0%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 3248
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0 主页面故障
Minor (reclaiming a frame) page faults: 254 次页面故障
Voluntary context switches: 2
Involuntary context switches: 0
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
主页面故障: 当程序执行的时候,如果需要数据在内存中没有,就会产生主页面故障
次页面故障: 当程序执行的时候,需要的数据直接在内存中得到,就会产生页面故障
内核调度和自身调优:就是不断减少主页面故障,增加次页面故障
查看内存分页情况
# yum install procinfo -y (安装软件)
# procinfo -n3
Memory: Total Used Free Shared Buffers Cached
Mem: 4184576 4143876 40700 0 1020948 2819268
Swap: 12586888 25744 12561144
Bootup: Tue Jun 4 17:38:06 2013 Load average: 0.02 0.01 0.00 1/250 24424
user : 2:49:55.58 0.1% page in : 151801646 disk 1: 2411948r27929765w
nice : 0:00:20.37 0.0% page out: 1164277021 disk 2: 271r 0w
system: 1:44:12.85 0.0% page act: 28374089 disk 3: 250r 0w
IOwait: 1d 6:41:46.08 1.1% page dea: 2610283
hw irq: 0:00:00.00 0.0% page flt: 184984723
sw irq: 0:23:00.97 0.0% swap in : 4261
idle : 111d 22:24:14.12 98.4% swap out: 30399
steal : 6:56:39.11 0.2%
uptime: 56d 20:24:57.55 context : 3295431496
irq 1: 2 i8042 irq823: 8366639 eth5-0
irq 4: 11 serial irq832:1001656270 timer
irq 8: 2 rtc0 irq833: 57010471 ipi
irq 9: 0 acpi irq834: 0 pcpu
irq 12: 4 i8042 irq835: 0 mce
irq 18: 0 uhci_hcd:usb4 irq836: 0 console
irq 19: 67 ata_piix, ata_piix, u irq837: 343466 xenbus [0] [1] [2 [7]
irq 23: 2 ehci_hcd:usb1, uhci_h irq838: 0 suspend
irq 24: 1623853 lpfc irq839: 5462043 blkif-backend
irq 32: 23733230 ioc0 irq840: 43 blkif-backend
irq 34: 1868961 lpfc irq841: 62621924 vif7.0
irq794: 0 eth4-2 irq842: 477069 blkif-backend
irq795: 0 eth4-1 irq843: 330846 blkif-backend
irq796: 1 eth4-0 irq844: 4255098 vif9.0
irq803: 3477198 eth2-2 irq845: 28702 blkif-backend
irq804: 4151377 eth2-1 irq846: 31 blkif-backend
irq805: 575565975 eth2-0 irq847: 663201 vif10.0
irq812: 0 eth6-2 irq848: 30686 blkif-backend
irq813: 0 eth6-1 irq849: 31 blkif-backend
irq814: 1 eth6-0 irq850: 243862 vif11.0
irq821: 55483005 eth5-2 irq851: 2875247 vif24.0
irq822: 43854772 eth5-1
查看当前主、次页面故障情况
# sar -B 2 3
14:13:38 pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff
14:13:40 0.00 0.00 21.39 0.00 241.29 0.00 0.00 0.00 0.00
14:13:42 0.00 336.00 415.00 0.00 835.00 0.00 0.00 0.00 0.00
14:13:44 0.00 28.14 20.60 0.00 200.50 0.00 0.00 0.00 0.00
Average: 0.00 121.33 152.33 0.00 425.67 0.00 0.00 0.00 0.00
转载于:https://blog.51cto.com/2364821/1261364