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.
the compiler will warn on it if it is removed.
arch/lkl/kernel/syscalls.c
Outdated
|
|
||
| void syscalls_cleanup(void) | ||
| { | ||
| struct thread_info *ti = task_thread_info(idle_host_task); |
There was a problem hiding this comment.
I think there is chance that this idle_host_task never runs. Safer to check if it's null first?
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 <jiangshanlai@gmail.com>
ffa8185 to
88f8dc2
Compare
liuyuan10
left a comment
There was a problem hiding this comment.
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 <jiangshanlai@gmail.com>
|
@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 <jiangshanlai@gmail.com>
|
reverted 9072b9a and pushed. Thanks for review! |
tavip
left a comment
There was a problem hiding this comment.
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