-
Notifications
You must be signed in to change notification settings - Fork 137
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
switch to idle_host_task when idle #336
Conversation
Can one of the admins verify this patch? |
This removes the call to cpu_idle_loop? We must run the cpu_idle_loop as it does some important jobs like time keeping setups. Also, removing NO_HZ is not good, as it will force generating interrupts when not needed, increasing the overhead. |
rest_init() -> cpu_startup_entry() -> cpu_idle_loop()
there is no important job if these is no interrupt nor syscalls.
I think the lkl-linux cpu is running on "host-task" in the "userspace" in most time, so you can't stop "generating interrupts". (correct me if I'm wrong.) We might need to add some change to NO_HZ_FULL and make it works for CPU0, thus we can use NO_HZ_FULL for "host-task". |
915cfbb
to
ffa8185
Compare
pr was rebased, and the NO_HZ_IDLE was preserved. |
@laijs I will need more time to review this, sorry. I will get back to you during the week-end. |
lkl_ops->sem_down(ti->sched_sem); | ||
if (idle_host_task == NULL) { | ||
lkl_ops->thread_exit(); | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the compiler will warn on it if it is removed.
arch/lkl/kernel/syscalls.c
Outdated
return 0; | ||
} | ||
|
||
void syscalls_cleanup(void) | ||
{ | ||
struct thread_info *ti = task_thread_info(idle_host_task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is chance that this idle_host_task never runs. Safer to check if it's null first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Add a idle_host_task, and the cpu will wake up the idle_host_task when enter idle. The idle_host_task simulates resuming userspace when scheduled. Thus the irqs and syscalls can enter the kernel directly. It also simplifies the idle code a lot, and removes the error-prone hacks. Signed-off-by: Lai Jiangshan <[email protected]>
ffa8185
to
88f8dc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test netperf TCP_RR on this patch?
I'm seeing it slows it down about 2x.
My guess is that the new idle_host_task has a higher priority so it takes longer for the application thread waiting on socket read to preempt it.
cd tools/lkl
sh tests/run_netperf.sh 192.168.13.1 5 0 TCP_RR
Signed-off-by: Lai Jiangshan <[email protected]>
@liuyuan10 added a commit to fix it. |
This does not look right to me. The cpu_idle_loop() has effectively been replaced with idle_host_task_loop() but they are not equivalent. In particular it is missing at least tick_nohz_idle_enter() / tick_nohz_idle_exit(), quiet_vmstat() and rcu_idle_enter()/rcu_idle_exit() which is needed even in our use-case. Even if we fix these missing calls, I don't like messing with cpu_idle_loop() as it may change in the future and that will make it difficult to maintain it. |
Please remember, in most cases, the lkl-linux is in the "userspace" context, rather than idle mode. |
OK, it now makes sense and it looks good to me. Can you also revert 9072b9a ("lkl: expose cpu_idle_loop from idle.c") as it looks like we don't need it? Sorry it took so long to review this. |
cpu_idle_loop() is unneeded to be exposed since the lkl will switch to the idle_host_task when idle, and the hack for cpu_idle_loop() is unneeded. Signed-off-by: Lai Jiangshan <[email protected]>
reverted 9072b9a and pushed. Thanks for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @liuyuan10 can you also take a look and let us know if this works on your setup?
@lkl-jenkins: test this please |
LGTM. thanks for cleaning it up. |
just a side note after a trial with my private branch (PR #255). I faced a trouble which no irqs are triggered after this update, and it turned out that an incomplete TLS implementation (there is tls_alloc() but always returns NULL) doesn't work well with this patch. if I updated the initialization of idle_host_task_loop like below, everything works fine. I think we don't need to change this but just for your information.
|
Because idle_host_task is NULL on this incomplete TLS implementation, I thought the lkl-kernel is considered fails on setup in this case. We need to change the initialization as your code or make the caller of syscall_init() respect the return value, or both. |
Add a idle_host_task, and the cpu will wake up the
idle_host_task when enter idle.
The idle_host_task simulates resuming userspace
when scheduled. Thus the irqs and syscalls can
enter the kernel directly.
It also simplifies the idle code a lot, and
removes the error-prone hacks.
This change is