From: Andrew Morton <akpm@linux-foundation.org>
To: Huacai Chen <chenhuacai@loongson.cn>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
"Eric W . Biederman" <ebiederm@xmission.com>,
Kees Cook <keescook@chromium.org>,
chenhuacai@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V1] kthread: Unify kernel_thread() and user_mode_thread()
Date: Mon, 5 Jun 2023 16:10:52 -0700 [thread overview]
Message-ID: <20230605161052.033ebe4cecc0a9c879d43f56@linux-foundation.org> (raw)
In-Reply-To: <20230603015302.1768127-1-chenhuacai@loongson.cn>
On Sat, 3 Jun 2023 09:53:02 +0800 Huacai Chen <chenhuacai@loongson.cn> 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.
next prev parent reply other threads:[~2023-06-05 23:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-03 1:53 Huacai Chen
2023-06-05 23:10 ` Andrew Morton [this message]
2023-06-05 23:21 ` Luis Chamberlain
2023-06-06 0:57 ` Kees Cook
2023-06-15 12:09 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230605161052.033ebe4cecc0a9c879d43f56@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=ebiederm@xmission.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®