From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>, Tejun Heo <tj@kernel.org>,
Petr Mladek <pmladek@suse.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Michal Hocko <mhocko@suse.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>
Subject: [PATCH 1/3] kthread: Remove the flags argument from kernel_thread
Date: Sun, 26 Jun 2022 14:15:48 -0500 [thread overview]
Message-ID: <87czevutgb.fsf_-_@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <87ilonuti2.fsf_-_@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Sun, 26 Jun 2022 14:14:45 -0500")
There are only two callers of kernel_thread remaining. The calling in
init/main.c that creates kthreadd, and the caller in kernel/kthread.c
Both callers pass CLONE_FS|CLONE_FILES. The argument SIGCHLD causes
terminate to exit with the oridnary process SIGCHLD semantics.
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.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
include/linux/sched/task.h | 2 +-
init/main.c | 2 +-
kernel/fork.c | 3 ++-
kernel/kthread.c | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index 505aaf9fe477..d95930e220da 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -91,7 +91,7 @@ extern pid_t kernel_clone(struct kernel_clone_args *kargs);
struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node);
struct task_struct *fork_idle(int);
struct mm_struct *copy_init_mm(void);
-extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
+extern pid_t kernel_thread(int (*fn)(void *), void *arg);
extern pid_t user_mode_thread(int (*fn)(void *), void *arg, unsigned long flags);
extern long kernel_wait4(pid_t, int __user *, int, struct rusage *);
int kernel_wait(pid_t pid, int *stat);
diff --git a/init/main.c b/init/main.c
index 0ee39cdcfcac..211d38db0d16 100644
--- a/init/main.c
+++ b/init/main.c
@@ -701,7 +701,7 @@ noinline void __ref rest_init(void)
rcu_read_unlock();
numa_default_policy();
- pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
+ pid = kernel_thread(kthreadd, NULL);
rcu_read_lock();
kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
rcu_read_unlock();
diff --git a/kernel/fork.c b/kernel/fork.c
index 9d44f2d46c69..65909ded0ea7 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2694,8 +2694,9 @@ pid_t kernel_clone(struct kernel_clone_args *args)
/*
* Create a kernel thread.
*/
-pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
+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),
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 544fd4097406..c0505e6b7142 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -396,7 +396,7 @@ static void create_kthread(struct kthread_create_info *create)
current->pref_node_fork = create->node;
#endif
/* We want our own signal handler (we take no signals by default). */
- pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
+ pid = kernel_thread(kthread, create);
if (pid < 0) {
/* If user was SIGKILLed, I release the structure. */
struct completion *done = xchg(&create->done, NULL);
--
2.35.3
next prev parent reply other threads:[~2022-06-26 19:15 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 14:08 [PATCH] workqueue: Make create_worker() safe against spurious wakeups Petr Mladek
2022-06-23 7:00 ` Petr Mladek
2022-06-23 7:14 ` Michal Hocko
2022-06-25 5:00 ` re. Spurious wakeup on a newly created kthread Tejun Heo
2022-06-25 17:01 ` Linus Torvalds
2022-06-25 17:36 ` Eric W. Biederman
2022-06-25 18:25 ` Linus Torvalds
2022-06-25 18:43 ` Linus Torvalds
2022-06-25 23:28 ` Eric W. Biederman
2022-06-25 23:41 ` Eric W. Biederman
2022-06-25 23:43 ` Linus Torvalds
2022-06-25 23:48 ` Linus Torvalds
2022-06-26 0:19 ` Eric W. Biederman
2022-06-27 0:01 ` Wedson Almeida Filho
2022-06-27 7:11 ` Peter Zijlstra
2022-06-27 18:23 ` Wedson Almeida Filho
2022-06-27 18:45 ` Linus Torvalds
2022-06-26 19:14 ` [PATCH 0/3] kthread: Stop using TASK_UNINTERRUPTIBLE Eric W. Biederman
2022-06-26 19:15 ` Eric W. Biederman [this message]
2022-06-26 21:20 ` [PATCH 1/3] kthread: Remove the flags argument from kernel_thread Linus Torvalds
2022-06-26 19:16 ` [PATCH 2/3] kthread: Replace kernel_thread with new_kthread Eric W. Biederman
2022-06-26 19:16 ` [PATCH 3/3] kthread: Stop abusing TASK_UNINTERRUPTIBLE (INCOMPLETE) Eric W. Biederman
2022-06-26 19:59 ` Linus Torvalds
2022-06-26 20:23 ` Tejun Heo
2022-06-26 20:55 ` Linus Torvalds
2022-06-27 7:22 ` Peter Zijlstra
2022-06-27 8:11 ` Tejun Heo
2022-06-27 18:04 ` Wedson Almeida Filho
2022-06-27 22:06 ` Peter Zijlstra
2022-06-27 22:34 ` Linus Torvalds
2022-06-27 22:45 ` Wedson Almeida Filho
2022-06-28 0:32 ` Wedson Almeida Filho
2022-06-28 7:58 ` Peter Zijlstra
2022-06-30 0:57 ` Wedson Almeida Filho
2022-06-26 22:14 ` kernel test robot
2022-06-26 22:34 ` kernel test robot
2022-06-26 0:21 ` re. Spurious wakeup on a newly created kthread Eric W. Biederman
2022-06-28 14:16 ` Christian Brauner
2022-06-26 0:26 ` Eric W. Biederman
2022-06-26 1:58 ` Tejun Heo
2022-06-26 2:53 ` Linus Torvalds
2022-06-26 6:09 ` Tejun Heo
2022-06-27 12:04 ` Michal Hocko
2022-06-28 9:51 ` Petr Mladek
2022-06-28 10:07 ` Tejun Heo
2022-06-27 8:07 ` Michal Hocko
2022-06-27 8:21 ` Tejun Heo
2022-06-27 10:18 ` Michal Hocko
2022-06-28 15:08 ` Petr Mladek
2022-08-04 8:57 ` [PATCH] workqueue: Make create_worker() safe against spurious wakeups Lai Jiangshan
2022-08-04 10:19 ` Lai Jiangshan
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=87czevutgb.fsf_-_@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.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