Cost of a page fault trap

╄→尐↘猪︶ㄣ 提交于 2019-12-03 13:15:57

You can do the rough math for an educated guess yourself. Assuming no disk access (~10 billion cycles), you have to account for

  • 160 cycles for the trap and returning (approximately, on x86_64)
  • validity checks, quota, accounting, and whatnot (unknown, probably a few hundred to a thousand cycles)
  • aligned memcpy of 4096 bytes, something around 500-800 cycles
  • TLB invalidation (adds 10-100 cycles on first access)
  • either eviction of other cached data or one guaranteed cache miss (80-400 cycles) depending on the implementation of the memcpy. It matters a lot on your access pattern whether one or the other is better.

So all in all, we're talking of something around 2000 cycles, with some of the effects (e.g. TLB and cache effects) being spread out and not immediately visible. Omondi and Sedukhin reported 1700 cycles on P-III back in 2003, which is consistent with this estimate.

Note that if the page has never been written to before, things are slightly different according to a comment by L. Torvalds back in 2000. A copy-on-write miss on a zero page pulls another zero page from the pool and doesn't copy zeroes. That's pretty much a guaranteed cache miss too, though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!