linux缺页实验,Linux缺页分析

CentOS Linux release 7.6.1810 (Core)

sar(System Activity Reporter系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况、系统调用的使用情况、磁盘I/O、CPU效率、内存使用状况、进程活动及IPC有关的活动等。

一、SAR

例如,每10秒采样一次,连续采样3次,监控内存分页:

sar -B 3 10

屏幕显示如下:

10时19分33秒 pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff

10时19分36秒 755.70 24915.44 2027.52 0.00 2383.89 0.00 0.00 0.00 0.00

10时19分39秒 1731.10 6022.74 3009.36 9.70 3995.65 3246.15 0.00 2455.52 75.64

10时19分42秒 1789.90 5255.22 180698.99 4.71 59192.59 0.00 0.00 0.00 0.00

10时19分45秒 159.47 3347.51 8969.77 0.66 8104.32 5120.60 0.00 4648.50 90.78

10时19分48秒 16.00 13773.33 908.00 0.00 4860.67 3460.67 0.00 3459.33 99.96

10时19分51秒 50.67 36790.67 1024.33 0.00 7102.00 5184.67 0.00 4546.67 87.69

10时19分54秒 4966.78 842.03 116652.88 0.00 50455.93 0.00 0.00 0.00 0.00

10时19分57秒 5040.00 1256.95 142171.53 0.00 59273.90 0.00 0.00 0.00 0.00

10时20分00秒 3255.41 0.00 160861.15 0.00 66245.27 0.00 0.00 0.00 0.00

10时20分03秒 1068.92 1036.49 138847.30 6.42 56104.73 0.00 0.00 0.00 0.00

10时20分06秒 1949.83 0.00 167713.56 0.00 67651.86 0.00 0.00 0.00 0.00

10时20分09秒 3922.18 1089.42 136153.24 0.00 55177.47 0.00 0.00 0.00 0.00

10时20分12秒 3027.80 4193.90 107734.58 0.00 44814.58 0.00 0.00 0.00 0.00

10时20分15秒 1836.24 16851.01 29327.52 22.82 22041.28 1611.07 0.00 1611.07 100.00

10时20分18秒 0.00 0.00 3133.11 0.00 5320.40 1545.15 0.00 1545.15 100.00

10时20分21秒 5.32 312.29 4233.89 0.00 1430.23 0.00 0.00 0.00 0.00

10时20分24秒 2774.24 6.78 92054.58 7.12 34281.69 1406.44 0.00 1398.98 99.47

10时20分27秒 150.67 6654.67 83092.33 1.33 40157.67 0.00 0.00 0.00 0.00

10时20分30秒 117.33 0.00 108808.67 1.33 42001.00 0.00 0.00 0.00 0.00

10时20分33秒 0.00 89.33 134465.33 0.00 53783.00 0.00 0.00 0.00 0.00

平均时间: 1619.28 6145.88 80746.68 2.70 34088.56 1085.59 0.00 989.42 91.14

输出项说明:

pgpgin/s:表示每秒从磁盘或SWAP置换到内存的字节数(KB)

pgpgout/s:表示每秒从内存置换到磁盘或SWAP的字节数(KB)

fault/s:每秒钟系统产生的缺页数,即主缺页与次缺页之和(major + minor)

majflt/s:每秒钟产生的主缺页数.

pgfree/s:每秒被放入空闲队列中的页个数

pgscank/s:每秒被kswapd扫描的页个数

pgscand/s:每秒直接被扫描的页个数

pgsteal/s:每秒钟从cache中被清除来满足内存需要的页个数

%vmeff:每秒清除的页(pgsteal)占总扫描页(pgscank+pgscand)的百分比

二、/usr/bin/time

# /usr/bin/time -v date

2019年 08月 01日 星期四 10:44:15 CST

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): 768

Average resident set size (kbytes): 0

Major (requiring I/O) page faults: 0

Minor (reclaiming a frame) page faults: 238

Voluntary context switches: 1

Involuntary context switches: 1

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

三、缺页中断

可分为下面两种

主缺页中断(Major Page Fault)

要从磁盘读取数据而产生的中断是主缺页中断

次缺页中断(Minor Page Fault)

数据已经被读入内存并被缓存起来,从内存缓存区中而不是直接从硬盘中读取数据而产生的中断是次缺页中断。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值