Re: [PATCH V1] kthread: Unify kernel_thread() and user_mode_thread()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat,  3 Jun 2023 09:53:02 +0800 Huacai Chen <chenhuacai@xxxxxxxxxxx> wrote:

> Commit 343f4c49f2438d8 ("kthread: Don't allocate kthread_struct for init
> and umh") introduces a new function user_mode_thread() for init and umh.
> 
> init and umh are different from typical kernel threads since the don't
> need a "kthread" struct and they will finally become user processes by
> calling kernel_execve(), but on the other hand, they are also different
> from typical user mode threads (they have no "mm" structs at creation
> time, which is traditionally used to distinguish a user thread and a
> kernel thread).
> 
> So I think it is reasonable to treat init and umh as "special kernel
> threads". Then let's unify the kernel_thread() and user_mode_thread()
> to kernel_thread() again, and add a new 'user' parameter for init and
> umh.
> 
> This also makes code simpler. 

Seems fair enough.

If we're attached to the naming then we could do

static inline pid_t user_mode_thread(int (*fn)(void *), void *arg,
				     unsigned long flags)
{
	return __kernel_thread(fn, arg, flags, 0);
}

static inline pid_t kernel_thread(int (*fn)(void *), void *arg,
				     unsigned long flags)
{
	return __kernel_thread(fn, arg, flags, 1);
}

(and pass the 4th arg straight into .kthread to avoid the !user thing)


But the naming isn't very good anyway.  Should have been
usermode_thread/kernel_thread or user_thread/kernel_thread.






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux