-
Notifications
You must be signed in to change notification settings - Fork 69
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
Supporting running kernel mode unit test in kernel threads #696
Comments
Be sure not to bloat the size of the framework since ktest should be designed as only depending on the framework. The scheduler does not reside in the framework. We can introduce a new macro API |
Which context does the main function labeled by Yes, the scheduler algorithm can be customized by the user of Asterinas Framework. But it is also true that Asterinas Framework supports running user-given kernel code in multiple tasks (or threads) out of the box. |
With #748 , we can support ktests which run kernel mode unit tests in a kernel thread context. However, the concurrent execution of multiple ktest tasks is still ongoing. I have tried to Incorporate the real execution function |
I won't worry about the code bloat of Asterinas Framework caused by adding a default scheduler to it. Here is the reasons. First of all, a simple FIFO scheduler can be implemented in less 100 LoC, may be 50 LoC. Such a degree of code bloat is acceptable. Second, this scheduler can be provided under a Cargo feature. This way, the users of the Framework can opt in or out the built-in scheduler depending the situation. For example, |
This is the original declaration: pub fn run_ktests<PrintFn, PathsIter>(
print: &PrintFn,
catch_unwind: &CatchUnwindImpl,
test_whitelist: Option<PathsIter>,
crate_whitelist: Option<&[&str]>,
) -> KtestResult; A suitable one would be: pub fn get_ktests<PrintFn, PathsIter>(
print: &PrintFn,
catch_unwind: &CatchUnwindImpl,
test_whitelist: Option<PathsIter>,
crate_whitelist: Option<&[&str]>,
) -> impl Iterator<Item=impl FnOnce<(), KtestResult>> You could do it within 100 lines of modification in |
Thanks for your advice. I will try to make as small a modification as possible. |
Background
The problem arises when attempting to add a kernel mode unit test for
CondVar
(#675).CondVar
is implemented based onWaitQueue
and supports similar wait-and-notify families of methods. These methods call the wait-and-wake methods ofWaitQueue
accordingly. However, the current issue is that kernel mode unit tests are not executed in a thread context, causing panic when thewait
method ofWaitQueue
yields the execution of the current thread.Brief
Our goal is to run kernel mode unit tests in a kernel thread context, which involves spawning a kernel thread for each test case. This approach offers performance improvements as we can leverage multicore processors by assigning each thread to a separate core. Additionally, it maintains consistency with the behavior of
cargo test
, where all test cases are run in parallel.Alternative
Alternatively, we could run all test cases in a single kernel thread instead of spawning a thread for each test case. However, this approach would result in poor performance.
Future Possibilities
If multiple kernel threads are involved, we must consider the scheduler. Initially, kernel mode unit tests can use the default FIFO scheduler. However, we may explore the option of setting different scheduling strategies.
The text was updated successfully, but these errors were encountered: