5

As we all know, kthreadd is a kernel thread, which is used to help others create new kernel threads (Review kthread_create_list to see if there is any new kernel thread need to create).

But I can not understand why we do not use create_kthread to create a new kernel thread? I do not see any difference kthreadd makes.

Could you give me some suggestions, please.

Thanks for your great help.

nponeccop
  • 13,527
  • 1
  • 44
  • 106
Dongguo
  • 379
  • 2
  • 4
  • 14
  • My *guess* (hence not writing it as an answer) would be that, since thread creation can be a lengthy process, the kernel just queues up thread creation requests for `kthreadd` to handle "later" so that the kernel itself can move on to something else - leading to lower overall latency and better performance. – twalberg Nov 15 '12 at 15:14

1 Answers1

2

Not Really. kthreadd is a daemon thread that runs in kernel space. The reason is that kernel needs to some times create threads but creating thread in kernel is very tricky. Hence kthreadd is a thread that kernel uses to spawn newer threads if required from there . This thread can access userspace address space also but should not do so . Its managed by kernel so one need not worry.

human.js
  • 1,342
  • 13
  • 15
  • My opinion: TO create a new thread in kernel, many shared object resources needed to modified. Normal kernel threads may also directly call the kernel_thread function to create threads, however, this may cause many many writer to the global shared resource and hence slow down the creating performance when in heavy load. – Houcheng Feb 26 '13 at 06:47