Uh oh!
There was an error while loading. Please reload this page.
Experimental PR for introducing klint - #958
Conversation
| /// | ||
| /// If the state matches the one we're waiting on, we wake up the task so that the future can be | ||
| /// polled again. | ||
| #[klint::preempt_count(expect = 0..)] // This function can be called from `wake_up` which must noy sleep. |
There was a problem hiding this comment.
nit:
| #[klint::preempt_count(expect = 0..)]// This function can be called from `wake_up` which must noy sleep. | |
| #[klint::preempt_count(expect = 0..)]// This function can be called from `wake_up` which must not sleep. |
| ) | ||
| } | ||
| #[klint::preempt_count(expect = 0..)] // Required as `Waker::clone` must not sleep. |
There was a problem hiding this comment.
Why Waker::clone must not sleep, could you elaborate?
There was a problem hiding this comment.
It is called by the callback passed to init_waitqueue_func_entry, which isn't allowed to sleep.
There was a problem hiding this comment.
Make senses, however, why do we need clone in wake_callback?
/me goes to search PR history
There was a problem hiding this comment.
Looks like this is done to invoke the waker after unlocking the mutex protecting the waker is released. I would expect this is to prevent a deadlock or something like that.
There was a problem hiding this comment.
Looks to me that we can just do the following
ifletSome(mut guard) = s.waker.try_lock(){ifletSome(w) = guard.take(){drop(guard);
w.wake();return1;}
|There was a problem hiding this comment.
Yeah, that's what I suggested in the meeting. But I didn't make the change because I think the whole NoWaitLock<Option<Waker>> thing should be replaced with AtomicWaker instead.
This is purely experimental and for demonstration purpose!
How to test it out:
cargo build --release)export LD_LIBRARY_PATH=$(rustup run 1.66.0 bash -c "echo \$LD_LIBRARY_PATH")make RUSTC=<path to klint binary>on kernel tree