Skip to content

kthreads: simplify !kthreadd_task logic, kill kthreadd_task_init_done

Oleg Nesterov lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1kthreads: simplify !kthreadd_task logic, kill kthreadd_task_init_doneinclude/linux/kthread.h init/main.c kernel/kthread.c+19 -240 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] kthreads: simplify !kthreadd_task logic, kill kthreadd_task_init_done
Quoted 18 lines · Oleg Nesterov
Quoted 16 lines · Ingo Molnar
Quoted 12 lines · Oleg Nesterov
Quoted 9 lines · Ingo Molnar
Quoted 4 lines · Oleg Nesterov

Yes, this should work. But I _think_ we can make the better fix...

I'll try to make the patch soon. Afaics we don't need kthreadd_task_init_done.

ok.

Just in case, the patch is ready. [...]

Quoted 8 lines
Quoted 6 lines

yes - that's roughly the cleanup i referred to in the commit log.

way too late for -rc8 though - the minimal fix i did _might_ be eligible.

agreed?

Agreed. Then I will sent the patch on top of this change.

OK, I am sending the patch on top of your fix. Not sure how to really test it, but at least the kernel works when I apply the debugging patch below on top.

Oleg.

init/main.c renamed from init/main.c~DBG +14 -1
@@ -455,7 +455,6 @@ static noinline void __init_refok rest_i
 {
 	kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
 	numa_default_policy();
-	kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
 	unlock_kernel();
 
 	/*
@@ -466,6 +465,12 @@ static noinline void __init_refok rest_i
 	rcu_scheduler_starting();
 	preempt_enable_no_resched();
 	schedule();
+
+	printk(KERN_INFO "XXX rest_init - sleeeeep\n");
+//	schedule_timeout_interruptible(HZ);
+	kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
+	printk(KERN_INFO "XXX rest_init - kthreadd started\n");
+
 	preempt_disable();
 
 	/* Call into cpu_idle with preempt disabled */
@@ -877,10 +882,18 @@ static noinline int init_post(void)
 	panic("No init found.  Try passing init= option to kernel.");
 }
 
+int ktfunc(void *arg)
+{
+	printk(KERN_INFO "XXX ktfunc - alive!\n");
+	return 0;
+}
+
 static int __init kernel_init(void * unused)
 {
 	lock_kernel();
 
+	printk(KERN_INFO "XXX kernel_init - call kthread_run, kthreadd=%p\n", kthreadd_task);
+	kthread_run(ktfunc, NULL, "xxx");
 	/*
 	 * init can allocate pages on any node
 	 */