From: "J. Bruce Fields" <bfields@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@redhat.com>,
David Howells <dhowells@redhat.com>, Tejun Heo <tj@kernel.org>,
Shaohua Li <shli@fb.com>, Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org,
"J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 4/4] kthreads: allow cloning threads with different flags
Date: Fri, 1 May 2020 12:01:52 -0400 [thread overview]
Message-ID: <1588348912-24781-5-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1588348912-24781-1-git-send-email-bfields@redhat.com>
From: "J. Bruce Fields" <bfields@redhat.com>
This is so knfsd can add CLONE_THREAD.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
include/linux/kthread.h | 3 ++-
kernel/kthread.c | 11 +++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index a7ffdf96a3b2..7069feb6da65 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -10,11 +10,12 @@ struct kthread_group {
spinlock_t create_lock;
struct list_head create_list;
struct task_struct *task;
+ unsigned long flags;
};
extern struct kthread_group kthreadd_default;
-struct kthread_group *kthread_start_group(char *);
+struct kthread_group *kthread_start_group(unsigned long, char *);
void kthread_stop_group(struct kthread_group *);
struct task_struct *kthread_group_create_on_node(struct kthread_group *,
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 5232f6f597b5..57f6687ecec7 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -29,6 +29,7 @@ struct kthread_group kthreadd_default = {
.name = "kthreadd",
.create_lock = __SPIN_LOCK_UNLOCKED(kthreadd_default.create_lock),
.create_list = LIST_HEAD_INIT(kthreadd_default.create_list),
+ .flags = CLONE_FS | CLONE_FILES | SIGCHLD,
};
void wake_kthreadd(struct kthread_group *kg)
@@ -36,7 +37,7 @@ void wake_kthreadd(struct kthread_group *kg)
wake_up_process(kg->task);
}
-struct kthread_group *kthread_start_group(char *name)
+struct kthread_group *kthread_start_group(unsigned long flags, char *name)
{
struct kthread_group *new;
struct task_struct *task;
@@ -47,6 +48,7 @@ struct kthread_group *kthread_start_group(char *name)
spin_lock_init(&new->create_lock);
INIT_LIST_HEAD(&new->create_list);
new->name = name;
+ new->flags = flags;
task = kthread_run(kthreadd, new, name);
if (IS_ERR(task)) {
kfree(new);
@@ -314,7 +316,8 @@ int tsk_fork_get_node(struct task_struct *tsk)
return NUMA_NO_NODE;
}
-static void create_kthread(struct kthread_create_info *create)
+static void create_kthread(struct kthread_create_info *create,
+ unsigned long flags)
{
int pid;
@@ -322,7 +325,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, flags);
if (pid < 0) {
/* If user was SIGKILLed, I release the structure. */
struct completion *done = xchg(&create->done, NULL);
@@ -645,7 +648,7 @@ void kthread_do_work(struct kthread_group *kg)
list_del_init(&create->list);
spin_unlock(&kg->create_lock);
- create_kthread(create);
+ create_kthread(create, kg->flags);
spin_lock(&kg->create_lock);
}
--
2.26.2
next prev parent reply other threads:[~2020-05-01 16:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 16:01 [PATCH 0/4] allow multiple kthreadd's J. Bruce Fields
2020-05-01 16:01 ` [PATCH 1/4] kthreads: minor kthreadd refactoring J. Bruce Fields
2020-05-01 16:01 ` [PATCH 2/4] kthreads: Simplify tsk_fork_get_node J. Bruce Fields
2020-05-01 16:01 ` [PATCH 3/4] kthreads: allow multiple kthreadd's J. Bruce Fields
2020-05-01 16:01 ` J. Bruce Fields [this message]
2020-05-01 17:59 ` [PATCH 0/4] " Linus Torvalds
2020-05-01 18:21 ` Tejun Heo
2020-05-01 18:30 ` Linus Torvalds
2020-05-01 19:02 ` J. Bruce Fields
2020-05-01 18:49 ` J. Bruce Fields
2020-05-01 19:05 ` Trond Myklebust
2020-05-01 19:20 ` tj
2020-05-01 19:22 ` J. Bruce Fields
2020-05-05 2:15 ` J. Bruce Fields
2020-05-05 15:54 ` Tejun Heo
2020-05-05 16:23 ` J. Bruce Fields
2020-05-05 21:01 ` J. Bruce Fields
2020-05-05 21:09 ` Tejun Heo
2020-05-05 21:25 ` J. Bruce Fields
2020-05-06 15:36 ` J. Bruce Fields
2020-05-06 15:39 ` Tejun Heo
2020-05-06 15:54 ` J. Bruce Fields
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=1588348912-24781-5-git-send-email-bfields@redhat.com \
--to=bfields@redhat.com \
--cc=dhowells@redhat.com \
--cc=jlayton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=shli@fb.com \
--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