Skip to content

Commit

Permalink
lkl: Fix memory leak of TIF_HOST_THREAD threads
Browse files Browse the repository at this point in the history
Now the TIF_HOST_THREAD threads are not properly killed.

Signed-off-by: Yuan Liu <liuyuan@google.com>
  • Loading branch information
liuyuan10 committed Nov 11, 2016
1 parent 8e4ddea commit c167ea8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions arch/lkl/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ int __init lkl_start_kernel(struct lkl_host_operations *ops,
}

lkl_ops->sem_down(init_sem);
lkl_ops->sem_free(init_sem);
current_thread_info()->tid = lkl_ops->thread_self();
lkl_cpu_change_owner(current_thread_info()->tid);

Expand Down
16 changes: 8 additions & 8 deletions arch/lkl/kernel/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ void threads_cnt_dec(void)

void threads_cleanup(void)
{
struct task_struct *p;
struct task_struct *p, *t;

for_each_process(p) {
struct thread_info *ti = task_thread_info(p);
for_each_process_thread(p, t) {
struct thread_info *ti = task_thread_info(t);

if (p->pid != 1)
WARN(!(p->flags & PF_KTHREAD),
"non kernel thread task %p\n", p->comm);
WARN(p->state == TASK_RUNNING,
"thread %s still running while halting\n", p->comm);
if (t->pid != 1 && !test_ti_thread_flag(ti, TIF_HOST_THREAD))
WARN(!(t->flags & PF_KTHREAD),
"non kernel thread task %s\n", t->comm);
WARN(t->state == TASK_RUNNING,
"thread %s still running while halting\n", t->comm);

kill_thread(ti);
}
Expand Down

0 comments on commit c167ea8

Please sign in to comment.