-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IrqDisabled variant which allows for re-enabling interrupts #1115
Comments
An orthogonal thing that makes sense is to make the |
This is a follow-up of !998 now that we have a better idea of what a design for enabling and disabling IRQs will look like. Currently, the most recent version of the patch series we have for interrupt management is here:
https://lkml.org/lkml/2024/8/1/1454
During the last re-spin of this series though, it was pointed out that there was a situation which I entirely missed.
with_irqs_disabled()
works great for simple situations where you just want to turn IRQs off for the duration of a callback, and then turn them back on afterwards. However, there's more complicated scenarios that can occur in the kernel. One such example that Benno provided:After quite a long discussion in https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/Spinlocks.20with.20IRQs.3F we were able to come up with a pretty decent idea for a solution to this that still allows the more simple
with_irqs_disabled
in its current form to remain safe code.Basically: once we start wanting to handle more complicated scenarios, we would:
OwnedIrqDisabled
type which can hand outIrqDisabled<'a>
tokenswith_irqs_disabled
towith_irqs_disabled_always
with_irqs_disabled
function that would provide access to anOwnedIrqDisabled
. This would come with a rather complicated safety contract.The safety contract would basically be something like this (I've just copied the summary I typed up already. Note, the examples are not complete!):
Currently this isn't part of the main series for the
irq
module, as I don't think we really have any users that need this quite yet.The text was updated successfully, but these errors were encountered: