|
|
Subscribe / Log in / New account

User-space interrupts

User-space interrupts

Posted Oct 3, 2021 2:25 UTC (Sun) by kepstin (subscriber, #72391)
In reply to: User-space interrupts by NYKevin
Parent article: User-space interrupts

I'm kinda confused about why hardware support is needed for this. For normally scheduled programs, as likely as not, the process being "interrupted" isn't actually running, so wouldn't the kernel need to step in and schedule the process before the interrupt could be delivered anyways? What's the benefit over a syscall there?

Or... Is this primarily for real time processes maybe? If the processes are carefully scheduled and known to be running concurrently on different cpus, I guess a direct userspace interrupt would be a win for latency.


to post comments

User-space interrupts

Posted Oct 3, 2021 18:35 UTC (Sun) by Bigos (subscriber, #96807) [Link]

I think the idea is: when two threads are running at the same time on different CPUs one can interrupt the other at an order of magnitude lower latency than the alternatives. The thread might be in the middle of execution of a long running task that does not touch any syscalls. And if the receiving thread is not running, the latency is not worse.

User mode scheduling (aka "green threads") was given as an example use case. If I understand correctly, one thread can preempt the other using a userspace interrupt. The interrupt handler can then modify the state so that on return something else is called, similar to how kernel scheduler works, but without any context switches. However, green threads are usually used when scheduling small short-living (or often-waiting) tasks, so cooperative preemption is enough. And when forceful preemption is necessary, it happens seldom enough for it not to be a bottleneck.

Jens Axboe mentioned io_uring cq notification [1], though that is about kernel -> userspace which has not been implemented yet.

There might be a better use case example that I am not thinking about. In fact, this has been stated as one of the issues on the mailing list [2].

At first, I wanted to point out that userspace RCU (URCU) could be a possible use case as well, but that was already resolved by membarrier() syscall years ago [3]. However, userspace interrupts might improve the performance of this even without broadcast support.

[1] https://lwn.net/ml/linux-kernel/ecf3cf2e-685d-afb9-1a5d-1...
[2] https://lwn.net/ml/linux-kernel/456bf9cf-87b8-4c3d-ac0c-7...
[3] https://lwn.net/Articles/369567/


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds