From patchwork Fri Feb 8 20:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Fields X-Patchwork-Id: 10803741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC90D13B5 for ; Fri, 8 Feb 2019 20:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF4C2EA09 for ; Fri, 8 Feb 2019 20:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 929BF2EA52; Fri, 8 Feb 2019 20:11:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32C6C2EA09 for ; Fri, 8 Feb 2019 20:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbfBHULY (ORCPT ); Fri, 8 Feb 2019 15:11:24 -0500 Received: from fieldses.org ([173.255.197.46]:57078 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727457AbfBHUKt (ORCPT ); Fri, 8 Feb 2019 15:10:49 -0500 Received: by fieldses.org (Postfix, from userid 2815) id EF646BCC; Fri, 8 Feb 2019 15:10:48 -0500 (EST) From: "J. Bruce Fields" To: linux-nfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Trond Myklebust , Jeff Layton , David Howells , Tejun Heo , Peter Zijlstra , Shaohua Li , Oleg Nesterov , "J. Bruce Fields" Subject: [PATCH 6/7] rpc: move rpc server threads into their own thread group Date: Fri, 8 Feb 2019 15:10:46 -0500 Message-Id: <1549656647-25115-7-git-send-email-bfields@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549656647-25115-1-git-send-email-bfields@redhat.com> References: <1549656647-25115-1-git-send-email-bfields@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "J. Bruce Fields" Signed-off-by: J. Bruce Fields --- 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);