From patchwork Tue Jun 20 23:35:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9800427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B02936038C for ; Tue, 20 Jun 2017 23:36:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 804D51FF8E for ; Tue, 20 Jun 2017 23:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74F9920410; Tue, 20 Jun 2017 23:36:18 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 207111FF8E for ; Tue, 20 Jun 2017 23:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428AbdFTXgR (ORCPT ); Tue, 20 Jun 2017 19:36:17 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34764 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbdFTXgQ (ORCPT ); Tue, 20 Jun 2017 19:36:16 -0400 Received: by mail-it0-f67.google.com with SMTP id y134so4643906itc.1 for ; Tue, 20 Jun 2017 16:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=EP6ZHaz4NOIurCbyrRn3RRGVIClDTnKX2fwsboyT5fY=; b=GRUNgbcBMIZMKNDDKiL2tq1covzrvkVZuFR5R+Imob9xGToIJ2yLp5kO3auHbrEc7s lw02mjCntFqEY+x4nakl9jSiUgRTi5CQoRVS5gWo/pGBF/c6xEwzZ6pAgGuQzhh2vxBT ASyEGY/Mg+vB6RGba4vqxd4rsUMWFGprkpXslQ1dEDFde8BRaXNToI0KWBA8rKIXMqMt MJ39C+hRl9wLASK8IGDgoeuGm5OcZmlghPCnfH4Ua1k5e4H3QtGStYyhWbhRxnMiSqLD sZ65AARhSJWaxaDQt/gqsHVRCCl62IyPVLitHy2+SCTQGUqoLzRKhU2TivifUA+TVH40 CPnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=EP6ZHaz4NOIurCbyrRn3RRGVIClDTnKX2fwsboyT5fY=; b=iR/vdWXbr8qoCUUAhxoip4+gMVFLnyIA592M3LTRVv3+XSszFJoSHLIqwJf+7xHUze ECqJvC4T5nMDIR9Os2LbY8/lbiC4LHpx8a8lTJ9j77ZkevtMM5PAtHjyJiQ73PEqGtSK B/9+tnDVUFcQY86B767GaiQ2Ggx7m3I6KQA7R9m5HYl6aJBuAkzTDMg9OEPczCmZ8EX9 0+k+Vcv/f/rbJeRHPXfNWnb4g3MM8Tj9tMTgvOWqXiYDoWuGtGYq214xCKvzOf7MUAVw MDoexnizZc6wr8UJyenE3d3F7FS2AG6SwARlN/p5mJ9tHQZcLKAQ8Zn6RB37KXG7wAv2 aurA== X-Gm-Message-State: AKS2vOzGQ+FYNqEkukG3frQ+Dvob7mYCQK+kKV0Mmdi5Syu81CQBS8dF V6UMro3QrlFvDw== X-Received: by 10.36.46.16 with SMTP id i16mr973398ita.41.1498001775774; Tue, 20 Jun 2017 16:36:15 -0700 (PDT) Received: from localhost.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id m129sm95277iom.27.2017.06.20.16.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 16:36:15 -0700 (PDT) From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] SUNRPC: Make slot allocation more reliable Date: Tue, 20 Jun 2017 19:35:39 -0400 Message-Id: <20170620233539.22417-5-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620233539.22417-4-trond.myklebust@primarydata.com> References: <20170620233539.22417-1-trond.myklebust@primarydata.com> <20170620233539.22417-2-trond.myklebust@primarydata.com> <20170620233539.22417-3-trond.myklebust@primarydata.com> <20170620233539.22417-4-trond.myklebust@primarydata.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 In xprt_alloc_slot(), the spin lock is only needed to provide atomicity between the atomic_add_unless() failure and the call to xprt_add_backlog(). We do not actually need to hold it across the memory allocation itself. By dropping the lock, we can use a more resilient GFP_NOFS allocation, just as we now do in the rest of the RPC client code. Signed-off-by: Trond Myklebust --- net/sunrpc/xprt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 3e63c5e97ebe..4654a9934269 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1047,13 +1047,15 @@ static bool xprt_throttle_congested(struct rpc_xprt *xprt, struct rpc_task *task return ret; } -static struct rpc_rqst *xprt_dynamic_alloc_slot(struct rpc_xprt *xprt, gfp_t gfp_flags) +static struct rpc_rqst *xprt_dynamic_alloc_slot(struct rpc_xprt *xprt) { struct rpc_rqst *req = ERR_PTR(-EAGAIN); if (!atomic_add_unless(&xprt->num_reqs, 1, xprt->max_reqs)) goto out; - req = kzalloc(sizeof(struct rpc_rqst), gfp_flags); + spin_unlock(&xprt->reserve_lock); + req = kzalloc(sizeof(struct rpc_rqst), GFP_NOFS); + spin_lock(&xprt->reserve_lock); if (req != NULL) goto out; atomic_dec(&xprt->num_reqs); @@ -1081,7 +1083,7 @@ void xprt_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task) list_del(&req->rq_list); goto out_init_req; } - req = xprt_dynamic_alloc_slot(xprt, GFP_NOWAIT|__GFP_NOWARN); + req = xprt_dynamic_alloc_slot(xprt); if (!IS_ERR(req)) goto out_init_req; switch (PTR_ERR(req)) {