开发者

low latency Interrupt handling (expected avg time to return from kernel to user space is?)

开发者 https://www.devze.com 2023-01-17 04:14 出处:网络
I have a Fibre Optic link, with a proprietary Device Driver. The link goes into a PCIe card. Running on a RHEL 5.2 (2.6.18-128~)

I have a Fibre Optic link, with a proprietary Device Driver.

The link goes into a PCIe card. Running on a RHEL 5.2 (2.6.18-128~)

I have mmap'ed the interface on the card for setup and FIFO access etc, and these read/writes take a few µs to complete, so all good there.

But of course cannot use this for interrupts, so I have to use the kernel module provided, with its user-space lib interface.

WaitForInterrupt(); // API lib interface to kernel module
// Interrupt occurs and am returned to my code in user space
time = CurrentTime() - LatchedTime(); // time to get to her开发者_如何学Ce

It takes around 70µs to return from WaitForInterrupt(). (The time the interrupt is raised is latched in the firmware, I read this which as I say above takes ~2µs, and compare it against the current time in the firmware)

What are expected access times between an interrupt occurring and the User Space API interrupt call wait method returning?

Network/other-high-speed interfaces take?


500ms is many orders of magnitudes larger than what a simple switch between userspace/kernel takes, but as someone mentioned in comments, linux is not a real time OS, so there's no guarantee 500ms "hickups" won't show up now and then.

It's quite impossible to tell what the culprit is, the device driver could simpliy be trying to bundle up data to be more efficient.

That said, we've had endless troubles with some custom cards and interactions with both APIC and ACPI, requireing a delicate balance of bios settings, what card goes into which PCI slot and whether a particular video card screws up everything - likely a cause of a dubious driver interacting with more or less buggy bios/video-cards..


If you're able to reliably exceed 500us on a system that's not heavily loaded, I think you're looking at a bad driver implementation (or its userspace wrapper/counterpart).

In my experience the latency to wake a user thread on interrupt should be less than 10us, though (as others have said) Linux provides no latency guarantees.


If you have a recent kernel, you can use the perf sched tool to measure the latency, and see where the time is being used. (500us does sound a tad on the high side, depending on your processor, how many tasks are running, ...)

0

精彩评论

暂无评论...
验证码 换一张
取 消