Re: [PATCH 1/3] kthread: Remove the flags argument from kernel_thread

From: Linus Torvalds
Date: Sun Jun 26 2022 - 17:29:21 EST


On Sun, Jun 26, 2022 at 12:15 PM Eric W. Biederman
<ebiederm@xxxxxxxxxxxx> wrote:
>
> As kthreadd never exists it simply does not matter what kind of exit
> it has. So for simplicity make it look like everything else and use
> SIGCHLD.

That "never exists" should be "never exits" ;)

But:

> +pid_t kernel_thread(int (*fn)(void *), void *arg)
> {
> + unsigned long flags = CLONE_FS | CLONE_FILES | SIGCHLD;
> struct kernel_clone_args args = {
> .flags = ((lower_32_bits(flags) | CLONE_VM |
> CLONE_UNTRACED) & ~CSIGNAL),

Please just get rid of that 'flags' thing, and the lower_32_bits()
games and write this all as

pid_t kernel_thread(int (*fn)(void *), void *arg)
{
struct kernel_clone_args args = {
.flags = CLONE_FS | CLONE_FILES |
CLONE_VM | CLONE_UNTRACED,
.exit_signal = SIGCHLD,
...

which does that whole thing much more clearly.

Linus