lkml.org 
[lkml]   [2023]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH RFC] kthread: Unify kernel_thread() and user_mode_thread()
Hi, Eric,

On Wed, May 10, 2023 at 11:45 PM Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> Huacai Chen <chenhuacai@loongson.cn> writes:
>
> > Commit 343f4c49f2438d8 ("kthread: Don't allocate kthread_struct for init
> > and umh") introduces a new function user_mode_thread() for init and umh.
> > But the name is a bit confusing because init and umh are indeed kernel
> > threads at creation time, the real difference is "they will become user
> > processes".
>
> No they are not "kernel threads" at creation time. At creation time
> init and umh are threads running in the kernel.
>
> It is a very important distinction and you are loosing it.
>
> Because they don't have a kthread_struct such tasks in the kernel
> are not allowed to depend on anything that is ``kthread''.
Hmm, traditionally, we call a "task" without userland address space
(i.e., the task_struct has no mm, it shares kernel's address space) as
a kernel thread, so init and umh are kernel threads until they call
kernel_execve(). Of course in your patch a kernel thread should have a
"kthread" struct (I can't grep "kthread_struct" so I suppose you are
saying "kthread"), but I think the traditional definition is more
natural for most people?

Huacai

>
> Having this a separate function highlights the distinction.
> Highlighting should hopefully cause people to ask why there is a
> distinction, and what is going on.
>
> > So let's unify the kernel_thread() and user_mode_thread() to
> > kernel_thread() again, and add a new 'user' parameter for init and
> > umh
>
> Now that is confusing.
>
> Eric

\
 
 \ /
  Last update: 2023-05-13 05:20    [W:1.145 / U:22.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site