为什么设备驱动程序会导致页面错误?
我有一个 Windows 控制台应用程序,它使用并行 IO 卡进行高速数据传输。 (通用标准HPDI32ALT)
我的进程正在用户模式下运行,但是,我确信在设备 API 后面的某个地方有一些内核模式驱动程序活动(PCI DMA 传输、读取设备状态寄存器等)。工作模型大致是这样的:
- 在启动时:我请求一个指向 IO 缓冲区的指针API。
- 在我的主循环中:
- 阻止 API 等待设备缓冲区中的空间(低水位线)
- 用传输数据填充 IO 缓冲区
- 通过将指向 IO 缓冲区的指针传递给设备开始传输(在此期间,API 使用 PCI 总线上的 DMA 将数据移动到卡)
- 阻止 API 等待 IO 完成
具有适当的数据速率和持续的吞吐量很长一段时间,但是,当我在 sys 内部工具进程资源管理器中查看进程时,我看到大量页面故障(每秒约 6k)。我正在以大约 30MB/s 的速度向卡移动。
我有足够的 RAM,并且有理由确信页面错误与磁盘 IO 无关。
关于可能导致页面错误的原因有什么想法吗?我还有一个该应用程序的接收端,它在接收模式下使用相同的 IO 卡。 API 的接收模式使用不会导致大量页面错误。
将 IO 缓冲区移至内核模式的行为会导致页面错误吗?
I have a Windows console application that uses a parallel IO card for high speed data transmission. (General Standards HPDI32ALT)
My process is running in user mode, however, I am sure somewhere behind the device's API there is some kernel mode driver activity (PCI DMA transfers, reading device status registers etc..) The working model is roughly this:
- at startup: I request a pointer to an IO buffer from API.
- in my main loop:
- block on API waiting for room in device's buffer (low watermark)
- fill the IO buffer with transmission data
- begin transmission to device by passing it the pointer to the IO buffer (during this time the API uses DMA on PCI bus to move the data to the card)
- block on API waiting for IO to complete
The application appears to be working correctly with proper data rate and sustained throughput for long periods of time, however, when I look at the process in sys internals tool process explorer I see a large number of page faults (~6k per second). I am moving ~30MB/s to the card.
I have plenty of RAM and am reasonably sure the page faults are not disk IO related.
Any thoughts on what could be causing the page faults? I also have a receive side to this application that is using an identical IO card in receive mode. The receive mode use of the API does not cause a large number page faults.
Could the act of moving the IO buffer to kernel mode cause page faults?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,您的应用程序向驱动程序请求内存缓冲区,然后将发送数据复制到该缓冲区中?这是一个非常奇怪的模型,通常您让应用程序管理缓冲区。
如果每秒 6K 页出现故障,而每秒仅传输 30MB,则几乎每传输一个页面都会出现一次页面错误。当您从驱动程序获取数据缓冲区时,它总是被零填充吗?我想知道您是否每次传输都要求零故障。
-斯科特
So your application asks the driver for a memory buffer and you copy the send data into that buffer? That's a pretty strange model, usually you let the application manage the buffers.
If you're faulting 6K pages/s and you're only transfering 30MB/s, you're almost getting a page fault for every page you transfer. When you get the data buffer from the driver, is it always zero filled? I'm wondering if you're getting demand zero faults for every transfer.
-scott