[问题] 使用mlockall不能完全避免page fault?

楼主: wtchen (没有存在感的人)   2015-10-29 01:49:40
正在试着评估RPi中如果用mlockall把memory锁住会不会改善latency
用著名的cyclictest (v0.92)+perf得到以下结果:
sudo perf stat ./cyclictest -p 90 - m -c 0 -i 3000 -n -h 250 -q -l 10000
# Total: 000009985
# Min Latencies: 00038
# Avg Latencies: 00082
# Max Latencies: 00386
# Histogram Overflows: 00015
Performance counter stats for
'./cyclictest -p 90 -m -c 0 -i 3000 -n -h 250 -q -l 10000':
818.925000 task-clock (msec) # 0.027 CPUs utilized
13,362 context-switches # 0.016 M/sec
0 cpu-migrations # 0.000 K/sec
56 page-faults # 0.068 K/sec
471,078,551 cycles # 0.575 GHz (50.34%)
282,495,112 stalled-cycles-frontend # 59.97% frontend cycles idle (51.67%)
13,419,172 stalled-cycles-backend # 2.85% backend cycles idle (52.93%)
68,489,877 instructions # 0.15 insns per cycle
# 4.12 stalled cycles per insn (38.41%)
7,553,254 branches # 9.223 M/sec (30.02%)
1,627,813 branch-misses # 21.55% of all branches (34.01%)
30.232651000 seconds time elapsed
如果不加-m参数(不用mlockall):
sudo perf stat ./cyclictest -p 90 -c 0 -i 3000 -n -h 250 -q -l 10000
# Total: 000009988
# Min Latencies: 00038
# Avg Latencies: 00080
# Max Latencies: 00407
# Histogram Overflows: 00012
Performance counter stats for
'./cyclictest -p 90 -c 0 -i 3000 -n -h 250 -q -l 10000':
772.978000 task-clock (msec) # 0.026 CPUs utilized
13,363 context-switches # 0.017 M/sec
0 cpu-migrations # 0.000 K/sec
66 page-faults # 0.085 K/sec
444,135,743 cycles # 0.575 GHz (41.26%)
271,762,254 stalled-cycles-frontend # 61.19% frontend cycles idle (48.87%)
8,522,179 stalled-cycles-backend # 1.92% backend cycles idle (56.53%)
65,640,536 instructions # 0.15 insns per cycle
# 4.14 stalled cycles per insn (37.62%)
7,453,674 branches # 9.643 M/sec (34.44%)
1,584,489 branch-misses # 21.26% of all branches (25.24%)
30.197211000 seconds time elapsed
看起来Max latencies会因为-m变小一点
我的问题在于,page-faults只有因为-m变稍小一点,并没有完全解决
请问这是正常的吗?我还以为mlockall住就不会有PF了。
感谢
作者: yvb   2015-10-29 16:24:00
光加载程式本身text和libs, 就会发生很多次 page-faults 了.
楼主: wtchen (没有存在感的人)   2015-10-29 19:28:00
所以除了一开始initialize的部份以外,就不会再有PF了吗?
作者: yvb   2015-10-29 21:58:00
...... 你认为什么情况下会发生 page fault ?
楼主: wtchen (没有存在感的人)   2015-10-30 04:00:00
我以为当process因为sleep或time slice超过后被swap,之后重新回到memory才会有page fault的动作mlockall我看man,他的功用是preventing that memory from being paged to the swap所以我以为mlockall = no swap
作者: yvb   2015-10-30 16:51:00
你可能把 swapping (paging) 和 context switching 搞混了...要不要看一下 wikipedia 的资料, 或用 google 确认一下差别?
作者: final01 (牛顿运动定律)   2015-10-31 00:00:00
page fault是应该减少没错,可是cold page fault无法免
楼主: wtchen (没有存在感的人)   2015-10-31 00:06:00
我有一点混淆没错,不过我的用意是不要loop到一半sleep的时候variable被丢到swap,结果sleep完要找variable找不到而发生page fault这样从swap->RAM就要浪费时间load,使得timing不准确
作者: yvb   2015-11-07 05:35:00
除非主内存不足, kernel 不会没事乱搞 swapping...至于 timing 准不准确, 得看需要的精确度有多高...不同 CPU 做 context switching 的 overhead 也不同.

Links booklink

Contact Us: admin [ a t ] ucptt.com