Re: [RFC PATCH 11/13] x86/uintr: Introduce uintr_wait() syscall
From: Sohil Mehta
Date: Wed Sep 29 2021 - 00:56:31 EST
On 9/28/2021 8:30 PM, Andy Lutomirski wrote:
On Mon, Sep 13, 2021, at 1:01 PM, Sohil Mehta wrote:
Add a new system call to allow applications to block in the kernel and
wait for user interrupts.
When the application makes this syscall the notification vector is
Any new SENDUIPI that happens to hit the target CPU's ucode at a time when the kernel vector is enabled will deliver the interrupt. Any new SENDUIPI that happens to hit the target CPU's ucode at a time when a different UIPI-using task is running will *not* deliver the interrupt, unless I'm missing some magic. Which means that wakeups will be missed, which I think makes this whole idea a nonstarter.
switched to a new kernel vector. Any new SENDUIPI will invoke the kernel
interrupt which is then used to wake up the process.
Am I missing something?
The current kernel implementation reserves 2 notification vectors (NV)
for the 2 states of a thread (running vs blocked).
NV-1 – used only for tasks that are running. (results in a user
interrupt or a spurious kernel interrupt)
NV-2 – used only for a tasks that are blocked in the kernel. (always
results in a kernel interrupt)
The UPID.UINV bits are switched between NV-1 and NV-2 based on the state
of the task.
However, NV-1 is also programmed in the running task's MISC_MSR UINV
bits. This is what tells the ucode that the notification vector received
is for the user instead of the kernel.
NV-2 is never programmed in the MISC_MSR of a task. When NV-2 arrives on
any cpu there is never a possibility of it being detected as a User
Interrupt. It will always be delivered to the kernel.
Does this help clarify the above?
I just realized, we need to be careful when the notification vectors are
switched in the UPID. Any pending vectors detected after the switch
should abort the blocking call. The current code is wrong in a lot of
places where it touches the UPID.