From patchwork Tue May 30 18:15:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 9755049 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 A4A5C601D2 for ; Tue, 30 May 2017 18:15:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94722267EC for ; Tue, 30 May 2017 18:15:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8989426E39; Tue, 30 May 2017 18:15:19 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 88924267EC for ; Tue, 30 May 2017 18:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750761AbdE3SPR (ORCPT ); Tue, 30 May 2017 14:15:17 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:32945 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbdE3SPQ (ORCPT ); Tue, 30 May 2017 14:15:16 -0400 Received: by mail-it0-f67.google.com with SMTP id l145so10311217ita.0; Tue, 30 May 2017 11:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=IMmhrUi0tGN7PF0Rj8AuEJgeJ1ZukRvvMHf/WSvLct4=; b=U0mi2aIhfrt8vYYSmdnqVZzuYwr8f9dJ+Sg6beDIhpiapT+mmpaC8WuPzgIcqjSW5S MX19JyPynk3NQsbeqW7DgQvZzWsmdkKGZIkVWscOhBGZFZ+2MqrOPpnOWuEsuDqoUC7h 9rMGkGxvCCf56ibqSB3Hc8E2N9qfWE/jKw9Wk440iHOjkooJwcEz5GUzEnq/OxbO6aia n+PjuyEgfPM2bhREF0T10UG9JdTmfzZi+EX+OPldR9Xn9gLTUV4RLq8Zqw4YTH+19LSy SzHiM6y0OHYxaR+hoaHgh4ZNzeSbi4dHijwciNiDzfHk/3pNdUwRAbTLJbQXbRb8pqKK mQPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=IMmhrUi0tGN7PF0Rj8AuEJgeJ1ZukRvvMHf/WSvLct4=; b=EP4XTGNPpwEf/H2bqR5MVNcYfyfo3f/u2SctfOU30qsC5dM+i+o9VXAEnZuEkzyUDZ zj9fSQho+wA3wI6PZ2AGs4lHWDLU5jW3xvCoZy49jZXPFRW9PtkPU/Zn5r5+WOsGepWY dqBz1pdJunlwDMAZYN+w6U1Zj8ZYj3dxir0r6lOy8REh1zXgfPuDJZwxzAl6B+3yOjYk HJ2sr5+nLa9NjkS4h+uWxiFXhprfZgQh4PESFENaYwIvzdnTIEJ3nRSUj/6dSRsxilsR rIUjYUOsQXdG2oD3pBeAagzq5pfMHrgBTwcEydXq0cXR2rB8Y+jA8qfMkUcmwkeziNHi TDgQ== X-Gm-Message-State: AODbwcC3u8hvHNk92DBPK0tIKOZRhRzxBS3aPVYzQnEewoSlnEZgXsmb cfPlhWQNWHMXWArg X-Received: by 10.36.166.4 with SMTP id q4mr3227021ite.66.1496168115589; Tue, 30 May 2017 11:15:15 -0700 (PDT) Received: from klimt.1015granger.net (c-68-46-169-226.hsd1.mi.comcast.net. [68.46.169.226]) by smtp.gmail.com with ESMTPSA id 200sm9939531itl.7.2017.05.30.11.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:15:15 -0700 (PDT) Subject: [PATCH v1 09/17] sunrpc: Allocate one more page per svc_rqst From: Chuck Lever To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Tue, 30 May 2017 14:15:14 -0400 Message-ID: <20170530181514.2992.43204.stgit@klimt.1015granger.net> In-Reply-To: <20170530175808.2992.60365.stgit@klimt.1015granger.net> References: <20170530175808.2992.60365.stgit@klimt.1015granger.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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 svcrdma needs 259 pages for 1MB NFSv4.0 READ requests: - 1 page for the transport header and head iovec - 256 pages for the data payload - 1 page for the trailing GETATTR request (since NFSD XDR decoding does not look for a tail iovec, the GETATTR is stuck at the end of the rqstp->rq_arg.pages list) - 1 page for building the reply xdr_buf Note that RPCSVC_MAXPAGES is defined as: ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2 + 1) I don't understand why the "+PAGE_SIZE-1" is in there, because division will always round the result down to (RPCSVC_MAXPAYLOAD / PAGE_SIZE + 2 + 1) Let's remove the "-1" to get 260 pages maximum. Then svc_alloc_args() needs to ask for pages according to this same formula, otherwise it will never allocate enough. Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 3 +-- net/sunrpc/svc_xprt.c | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 9463102..682cd7c 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -176,8 +176,7 @@ static inline void svc_get(struct svc_serv *serv) * We using ->sendfile to return read data, we might need one extra page * if the request is not page-aligned. So add another '1'. */ -#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE \ - + 2 + 1) +#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD + PAGE_SIZE) / PAGE_SIZE + 2 + 1) static inline u32 svc_getnl(struct kvec *iov) { diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 7bfe1fb..9bd484d 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -659,11 +659,13 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) int i; /* now allocate needed pages. If we get a failure, sleep briefly */ - pages = (serv->sv_max_mesg + PAGE_SIZE) / PAGE_SIZE; - WARN_ON_ONCE(pages >= RPCSVC_MAXPAGES); - if (pages >= RPCSVC_MAXPAGES) + pages = (serv->sv_max_mesg + (2 * PAGE_SIZE)) >> PAGE_SHIFT; + if (pages >= RPCSVC_MAXPAGES) { + pr_warn_once("svc: warning: pages=%u >= RPCSVC_MAXPAGES=%lu\n", + pages, RPCSVC_MAXPAGES); /* use as many pages as possible */ pages = RPCSVC_MAXPAGES - 1; + } for (i = 0; i < pages ; i++) while (rqstp->rq_pages[i] == NULL) { struct page *p = alloc_page(GFP_KERNEL);