linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Trond Myklebust <trondmy@hammerspace.com>,
	Jeff Layton <jlayton@redhat.com>,
	David Howells <dhowells@redhat.com>, Tejun Heo <tj@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>, Shaohua Li <shli@fb.com>,
	Oleg Nesterov <oleg@redhat.com>,
	"J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 6/7] rpc: move rpc server threads into their own thread group
Date: Fri,  8 Feb 2019 15:10:46 -0500	[thread overview]
Message-ID: <1549656647-25115-7-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1549656647-25115-1-git-send-email-bfields@redhat.com>

From: "J. Bruce Fields" <bfields@redhat.com>

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 include/linux/sunrpc/svc.h |  1 +
 net/sunrpc/svc.c           | 23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index e52385340b3b..07d428dd067f 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -101,6 +101,7 @@ struct svc_serv {
 
 	unsigned int		sv_nrpools;	/* number of thread pools */
 	struct svc_pool *	sv_pools;	/* array of thread pools */
+	struct kthread_group *	sv_kthread_grp;
 	const struct svc_serv_ops *sv_ops;	/* server operations */
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
 	struct list_head	sv_cb_list;	/* queue for callback requests
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 502e09a28f84..d8586a57da40 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -464,10 +464,16 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 	serv->sv_pools =
 		kcalloc(serv->sv_nrpools, sizeof(struct svc_pool),
 			GFP_KERNEL);
-	if (!serv->sv_pools) {
-		kfree(serv);
-		return NULL;
-	}
+	if (!serv->sv_pools)
+		goto out_free_serv;
+
+	serv->sv_kthread_grp = kthread_start_group(CLONE_THREAD |
+					CLONE_SIGHAND | CLONE_VM | CLONE_FS |
+					CLONE_FILES | SIGCHLD,
+					serv->sv_name);
+
+	if (IS_ERR(serv->sv_kthread_grp))
+		goto out_free_pools;
 
 	for (i = 0; i < serv->sv_nrpools; i++) {
 		struct svc_pool *pool = &serv->sv_pools[i];
@@ -482,6 +488,11 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 	}
 
 	return serv;
+out_free_pools:
+	kfree(serv->sv_pools);
+out_free_serv:
+	kfree(serv);
+	return NULL;
 }
 
 struct svc_serv *
@@ -551,6 +562,7 @@ svc_destroy(struct svc_serv *serv)
 	if (svc_serv_is_pooled(serv))
 		svc_pool_map_put();
 
+	kthread_stop_group(serv->sv_kthread_grp);
 	kfree(serv->sv_pools);
 	kfree(serv);
 }
@@ -719,7 +731,8 @@ svc_start_kthread(struct svc_serv *serv, struct svc_pool *pool,
 		return PTR_ERR(rqstp);
 
 	__module_get(serv->sv_ops->svo_module);
-	task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp,
+	task = kthread_group_create_on_node(serv->sv_kthread_grp,
+				      serv->sv_ops->svo_function, rqstp,
 				      node, "%s", serv->sv_name);
 	if (IS_ERR(task)) {
 		module_put(serv->sv_ops->svo_module);
-- 
2.20.1


  parent reply	other threads:[~2019-02-08 20:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-08 20:10 [PATCH 0/7] Eliminate delegation self-conflicts J. Bruce Fields
2019-02-08 20:10 ` [PATCH 1/7] kthreads: minor kthreadd refactoring J. Bruce Fields
2019-02-08 20:10 ` [PATCH 2/7] kthreads: Simplify tsk_fork_get_node J. Bruce Fields
2019-02-08 20:10 ` [PATCH 3/7] kthreads: allow multiple kthreadd's J. Bruce Fields
2019-03-12 20:01   ` J. Bruce Fields
2019-02-08 20:10 ` [PATCH 4/7] kthreads: allow cloning threads with different flags J. Bruce Fields
2019-02-08 20:10 ` [PATCH 5/7] rpc: separate out body of svc_start_kthreads J. Bruce Fields
2019-02-08 20:10 ` J. Bruce Fields [this message]
2019-02-08 20:10 ` [PATCH 7/7] nfsd: ignore delegation self-conflicts J. Bruce Fields
2019-02-09 12:43 ` [PATCH 0/7] Eliminate " Jeff Layton
2019-02-11 15:58   ` J. Bruce Fields
2019-02-15 16:35     ` 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=1549656647-25115-7-git-send-email-bfields@redhat.com \
    --to=bfields@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=shli@fb.com \
    --cc=tj@kernel.org \
    --cc=trondmy@hammerspace.com \
    /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;
as well as URLs for NNTP newsgroup(s).